|
Answer» The following:
xcopy c:\Nos\*.*/s d:\Nos\"%Date%"\*.*/Y works but it copies all the files in the directories and files that are not updated are also copied.
Saw the following: /D:m-d-y Copies files changed on or after the specified date. If no date is given, copies only those files whose source time is newer than the destination time
and have tried to incorporate it into the xcopy command above but have failed after MANY attempts and with many combinations.
Files that are not updated do not need to be copied.
I am new to ms dos.
Kindly help.
Thanks. Hi Hu,
It seems to work for me, using Windows XP. In the example below, I only copy files updated since 1st July ("7-1-2007") to a "target" directory.
Code: [Select]D:\test> DIR Volume in drive D is DATA Volume SERIAL Number is 9842-52D0
Directory of D:\test
03/07/2007 10:17 <DIR> . 03/07/2007 10:17 <DIR> .. 03/07/2007 10:28 <DIR> target 03/07/2007 10:16 385 July.txt 26/06/2007 12:47 385 June.txt 2 FILE(s) 770 bytes 3 Dir(s) 89,285,689,344 bytes free
D:\test> XCOPY /D:7-1-2007 *.* target D:July.txt 1 File(s) copied
D:\test>
Please can you paste & POST an example directory listing that you are trying to copy, together with the output generated by your XCOPY, and I will try to replicate/investigate on my PC.
Thanks, JamesHi Hu,
I've had an additional thought. If you want to use the system variable "%DATE%" as the "XCOPY date", then you need to convert the date format from dd/mm/yyyy to mm-dd-yyyy.
To do this, use a batch file Similar to the one below. (I have named mine "backup.bat")
Code: [Select]for /F "delims=/ tokens=1-3" %%A in ('echo %%DATE%%') do XCOPY /F/I/D:%%B-%%A-%%C *.* %%B-%%A-%%C
Here is an example of this batch file being used on Windows XP:
Code: [Select]D:\test> DIR Volume in drive D is DATA Volume Serial Number is 9842-52D0
Directory of D:\test
03/07/2007 12:56 <DIR> . 03/07/2007 12:56 <DIR> .. 03/07/2007 12:50 100 backup.bat 03/07/2007 10:16 385 July.txt 26/06/2007 12:47 385 June.txt 3 File(s) 870 bytes 2 Dir(s) 89,292,156,928 bytes free
D:\test> BACKUP
D:\test>for /F "delims=/ tokens=1-3" %A in ('echo %DATE%') do XCOPY /F/I/D:%B-%A-%C *.* %B-%A-%C
D:\test>XCOPY /F/I/D:07-03-2007 *.* 07-03-2007 D:\test\backup.bat -> D:\test\07-03-2007\backup.bat D:\test\July.txt -> D:\test\07-03-2007\July.txt 2 File(s) copied
D:\test> DIR 07-03-2007 Volume in drive D is DATA Volume Serial Number is 9842-52D0
Directory of D:\test\07-03-2007
03/07/2007 12:56 <DIR> . 03/07/2007 12:56 <DIR> .. 03/07/2007 12:50 100 backup.bat 03/07/2007 10:16 385 July.txt 2 File(s) 485 bytes 2 Dir(s) 89,292,144,640 bytes free
D:\test>
Hope that helps, JAMES
|