1.

Solve : Batch file keeps copying a few of the same files?

Answer»

I created a batch file with a scheduled task that copies files from C to D, no problem. I used the following switches /d /y /s. I then created the same batch file to copy from the D drive to a network drive G.

The problem is this: The initial copy works fine. Then when I run the batch file from D to G the next time and every time thereafter, there are a few files (just a few) it continues to copy. These files haven't changed so they shouldn't copy again. I'm thinking it has SOMETHING to do with the time/date stamp on the one computer to the other. But, if that were the CASE, why wouldn't that happen to all the files? I put a few test files on D as well and it continues to copy them over to G as well. Any suggestions for a resolution to this problem, are GREATLY appreciated.

Could this all have something to do with if the archive bit is cleared or not?I'm gonna take a wild guess that you're using XCOPY since COPY has no /s switch.

The /d switch according to Microsoft:

Quote

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.

Sounds like more of a date/time problem than the archive bit (the /k switch). Try using with a hardcoded date or one you develop in your batch file.

Happy Computing. 8-)I don't know how to use a hard coded date or develop one in a batch file. Please explain? Of course you were correct in that I an using Xcopy. Any and all help is welcome. ThankHardcoding a date would be something like this:

xcopy /d:12-31-2005 /y /s .....

Developing a date that moves from day to day in a batch file is problematic. Batch files do not do date/time arithmetic without jumping thru HOOPS.

Perhaps after each file(s) are copied, you could look into the ATTRIB command to set the archive bit and then use XCOPY with the /a switch so only files not archived are copied.

If you need to post back, please mention your OS.

Hope this gives you some ideas. 8-)


Discussion

No Comment Found