copy newer files to specific folder

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
chrisb421
Posts: 2
Joined: 28 Aug 2018 13:07

copy newer files to specific folder

#1 Post by chrisb421 » 28 Aug 2018 13:15

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.

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: copy newer files to specific folder

#2 Post by Squashman » 28 Aug 2018 13:49

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.

chrisb421
Posts: 2
Joined: 28 Aug 2018 13:07

Re: copy newer files to specific folder

#3 Post by chrisb421 » 28 Aug 2018 14:05

i guess it does. i changed the copy to xcopy and added the /D and /Y and it works now

Post Reply