Page 1 of 1

copy newer files to specific folder

Posted: 28 Aug 2018 13:15
by chrisb421
im using this command:

for /R C:\testfrom %%F in (*.zip) do @copy "%%F" C:\testto

and i want to search all the subdirectories and copy all the zip files and put them in one folder (no subfolders) and overwrite any files that are older.

the above command works in my batch file but will overwrite newer items in the target directory. i believe its a /D option I need to put in somewhere, but i don't know where. i figured it would go at the end of the line, but that didn't seem to do it. any help would be appreciated.

Re: copy newer files to specific folder

Posted: 28 Aug 2018 13:49
by Squashman
chrisb421 wrote:
28 Aug 2018 13:15
i believe its a /D option I need to put in somewhere, but i don't know where.
That would be true if you were using XCOPY.

The /D option of the COPY command does something completely different. Helps if you read the help files.

Re: copy newer files to specific folder

Posted: 28 Aug 2018 14:05
by chrisb421
i guess it does. i changed the copy to xcopy and added the /D and /Y and it works now