1.

Solve : shedule time for copy/transfer folders job?

Answer»

i want to copy 8 huge folders to external hardisk, but i want to do this one folder each time at schedule time, because those files may ACCESS by others during office hour.

so when i run it, it will only copy specific folder to ext HDD at schedule time (e.g 7/24/2010 12.00a.m)...and a log file will be generated when finished copy (e.g abc folder 1234 files copied at 7/24/2010 12.30a.m)...
i got this code to create data folder but SOMEHOW it doesn't work perfectly

Code: [Select]echo off
SET date="%date:~6,4%-%date:~0,2%-%date:~2,2%"

md D:\2\%date%
xcopy /e C:\1\*.* D:\2\%date%
pause
the folder create is D:\2\2010-07-\2

my system date format is
07/25/2010 Sun 15:22:52.92
xcopy /e C:\1\*.* D:\2\%date%

Prompt user for folder name

or
 use a command line argument

xcopy /e C:\%1\*.* D:\2\%date%
Rem  date is a command and should be used a variable name

Code: [Select]echo off
set MM=%date:~4,2%
set DD=%date:~7,2%
set YYYY=%date:~10,4%
echo MM=%MM%
echo DD=%DD%
echo YYYY=%YYYY%
set mydate=%MM%-%DD%-%YYYY%
echo mydate=%mydate%
pause
e:
cd 2

md %mydate%
copy C:\1\*.*  e:\2\%mydate%\

cd  e:\2\%mydate%\
dir
lon.bat
MM=07
DD=25
YYYY=2010
mydate=07-25-2010
Press any key to continue . . .

C:\1\world1.txt
C:\1\world2.txt
C:\1\world3.txt
        3 file(s) copied.
 Volume in drive E is My Book
 Volume Serial Number is 0850-D7C5

 Directory of e:\2\07-25-2010

07/25/2010  05:10 PM              .
07/25/2010  05:10 PM              ..
07/25/2010  05:10 PM              07-25-2010
07/25/2010  05:01 PM                16 world1.txt
07/25/2010  05:01 PM                16 world2.txt
07/25/2010  05:01 PM                16 world3.txt
             
e:\2\07-25-2010>Rem  date is a command and should be used a variable name

date is a command and should not be used as a variable name. Quote from: marylane on July 25, 2010, 08:14:36 PM

Rem  date is a command and should be used a variable name

date is a command and should not be used as a variable name.

%date% is already used as a system variable name, Bill, so it should not be modified or altered.
date is a command and should not be used as a variable name.
Quote from: only_lonely on July 25, 2010, 01:18:15 AM
i got this code to create data folder but somehow it doesn't work perfectly

Code: [Select]echo off
SET date="%date:~6,4%-%date:~0,2%-%date:~2,2%"

md D:\2\%date%
xcopy /e C:\1\*.* D:\2\%date%
pause
the folder create is D:\2\2010-07-\2

my system date format is
07/25/2010 Sun 15:22:52.92

date is a command and should not be used as a variable name.C:\>date /t
Mon 07/26/2010

C:\>echo %DATE%
Mon 07/26/2010

C:\>date
The current date is: Mon 07/26/2010
Enter the new date: (mm-dd-yy)

C:\> Quote from: marylane on July 26, 2010, 09:13:25 AM

C:\>date /t
Mon 07/26/2010

C:\>echo %DATE%
Mon 07/26/2010

C:\>date
The current date is: Mon 07/26/2010
Enter the new date: (mm-dd-yy)

C:\>
Yes, and your point is, Bill?The original poster( only_lonely )  used the command "date" as a personal variable:

echo off
SET date="%date:~6,4%-%date:~0,2%-%date:~2,2%"
Good job editing your post bill! Quote from: marylane on July 26, 2010, 09:24:40 AM
The original poster( only_lonely )  used the command "date" as a personal variable:

echo off
SET date="%date:~6,4%-%date:~0,2%-%date:~2,2%"


Bill, this may or may not be a bad IDEA, as thereafter in that session, (and only in that session) the system variable %date%, which is provided for the user's convenience, will be different from the default (as set in Regional Options in Control Panel). As I say, it may or may not be a bad thing. The sky won't fall, however, Bill.
Like I said, only in that session...


The following (reply 1 above ) is from the original poster, only_lonely.  The name given to the file was not  the goal.  Using a command, "date" as a personal variable  does not work
.

type ol726.bat
echo off
SET date="%date:~6,4%-%date:~0,2%-%date:~2,2%"
echo  date=%date%
pause

md e:\2\%date%
copy  C:\1\*.* e:\2\%date%

dir
ol726.bat
date="Mo-n-"/-26"
the above is mistake

Terminate batch job (Y/N)? y

p.s. It does not work for this session or any sessionBill posts his usual nonsense. Countdown to ban time...


Discussion

No Comment Found