1.

Solve : shedule time for copy/transfer folders job?

Answer» <html><body><p>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 <a href="https://interviewquestions.tuteehub.com/tag/access-846773" style="font-weight:bold;" target="_blank" title="Click to know more about ACCESS">ACCESS</a> by others during office hour.<br/><br/>so when i run it, it will only copy specific folder to ext <a href="https://interviewquestions.tuteehub.com/tag/hdd-479551" style="font-weight:bold;" target="_blank" title="Click to know more about HDD">HDD</a> 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)...<br/>i got this code to create data folder but <a href="https://interviewquestions.tuteehub.com/tag/somehow-7378511" style="font-weight:bold;" target="_blank" title="Click to know more about SOMEHOW">SOMEHOW</a> it doesn't work perfectly<br/><br/> Code: <a>[Select]</a>echo off<br/>SET date="%date:~6,4%-%date:~0,2%-%date:~2,2%"<br/><br/>md D:\2\%date%<br/>xcopy /e C:\1\*.* D:\2\%date%<br/>pause<br/>the folder create is D:\2\2010-07-\2<br/><br/>my system date format is <br/>07/25/2010 Sun 15:22:52.92<br/>xcopy /e C:\1\*.* D:\2\%date%<br/><br/>Prompt user for folder name <br/><br/>or<br/> use a command line argument<br/><br/>xcopy /e C:<strong>\%1</strong>\*.* D:\2\%date%<br/><strong>Rem  date is a command and should be used a variable name</strong><br/><br/> Code: <a>[Select]</a>echo off<br/>set MM=%date:~4,2%<br/>set DD=%date:~7,2%<br/>set YYYY=%date:~10,4%<br/>echo MM=%MM%<br/>echo DD=%DD%<br/>echo YYYY=%YYYY%<br/>set mydate=%MM%-%DD%-%YYYY%<br/>echo mydate=%mydate%<br/>pause<br/>e:<br/>cd 2<br/><br/>md %mydate%<br/>copy C:\1\*.*  e:\2\%mydate%\<br/><br/>cd  e:\2\%mydate%\<br/>dir<br/>lon.bat<br/>MM=07<br/>DD=25<br/>YYYY=2010<br/>mydate=07-25-2010<br/>Press any key to continue . . .<br/><br/>C:\1\world1.txt<br/>C:\1\world2.txt<br/>C:\1\world3.txt<br/>        3 file(s) copied.<br/> Volume in drive E is My Book<br/> Volume Serial Number is 0850-D7C5<br/><br/> Directory of e:\2\07-25-2010<br/><br/>07/25/2010  05:10 PM              .<br/>07/25/2010  05:10 PM              ..<br/>07/25/2010  05:10 PM              07-25-2010<br/>07/25/2010  05:01 PM                16 world1.txt<br/>07/25/2010  05:01 PM                16 world2.txt<br/>07/25/2010  05:01 PM                16 world3.txt<br/>              <br/>e:\2\07-25-2010&gt;Rem  date is a command and should be used a variable name<br/><br/><strong>date is a command and should not be used as a variable name.</strong> Quote from: marylane on July 25, 2010, 08:14:36 PM</p><blockquote>Rem  date is a command and should be used a variable name<br/><br/><strong>date is a command and should not be used as a variable name.</strong><br/></blockquote> <br/>%date% is already used as a system variable name, Bill, so it should not be modified or altered.<br/><strong>date is a command and should not be used as a variable name</strong>.<br/> Quote from: only_lonely on July 25, 2010, 01:18:15 AM<blockquote>i got this code to create data folder but somehow it doesn't work perfectly<br/><br/> Code: <a>[Select]</a>echo off<br/>SET date="%date:~6,4%-%date:~0,2%-%date:~2,2%"<br/><br/>md D:\2\%date%<br/>xcopy /e C:\1\*.* D:\2\%date%<br/>pause<br/>the folder create is D:\2\2010-07-\2<br/><br/>my system date format is <br/>07/25/2010 Sun 15:22:52.92<br/><br/></blockquote> <strong>date is a command and should not be used as a variable name.</strong>C:\&gt;date /t<br/>Mon 07/26/2010<br/><br/>C:\&gt;echo %DATE%<br/>Mon 07/26/2010<br/><br/>C:\&gt;date<br/>The current date is: Mon 07/26/2010<br/>Enter the new date: (mm-dd-yy)<br/><br/>C:\&gt; Quote from: marylane on July 26, 2010, 09:13:25 AM<blockquote><br/>C:\&gt;date /t<br/>Mon 07/26/2010<br/><br/>C:\&gt;echo %DATE%<br/>Mon 07/26/2010<br/><br/>C:\&gt;date<br/>The current date is: Mon 07/26/2010<br/>Enter the new date: (mm-dd-yy)<br/><br/>C:\&gt;<br/></blockquote> Yes, and your point is, Bill?The original poster( only_lonely )  used the command "date" as a personal variable:<br/><br/>echo off<br/><strong>SET date="%date:~6,4%-%date:~0,2%-%date:~2,2%</strong>"<br/>Good job editing your post bill! Quote from: marylane on July 26, 2010, 09:24:40 AM<blockquote>The original poster( only_lonely )  used the command "date" as a personal variable:<br/><br/>echo off<br/><strong>SET date="%date:~6,4%-%date:~0,2%-%date:~2,2%</strong>"<br/><br/></blockquote> <br/><strong>Bill,</strong> this may or may not be a bad <a href="https://interviewquestions.tuteehub.com/tag/idea-770073" style="font-weight:bold;" target="_blank" title="Click to know more about IDEA">IDEA</a>, 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, <strong>Bill</strong>.<br/>Like I said, only in that session...<br/><br/><strong><br/>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</strong>.<br/><br/>type ol726.bat<br/><strong>echo off<br/>SET date="%date:~6,4%-%date:~0,2%-%date:~2,2%"<br/>echo  date=%date%<br/>pause<br/><br/>md e:\2\%date%<br/>copy  C:\1\*.* e:\2\%date%<br/><br/>dir</strong>ol726.bat<br/><strong> date="Mo-n-"/-26"</strong><br/>the above is mistake<br/><br/>Terminate batch job (Y/N)? y<br/><br/>p.s. It does not work for this session or any sessionBill posts his usual nonsense. Countdown to ban time... <br/></body></html>


Discussion

No Comment Found