cjxmccac
cjxmccac

Reputation: 1

Copyfiles from Directory Tree to Flat Folder - Keep most Recent

I am trying to create a batch file that will allow me to copy files that are scattered across several directories into a single location while maintaining the most recent copy available. This is for a Windows machine.

For example...

C:\Base Files\*.jpg
C:\Base Files\Sub\*.jpg
C:\Base Files\Sub2\*.jpg

and copy all of these to C:\Backup.

I am trying to do something like the following...

FORFILES /p "C:\Base Files\DIR01\My Images" /s /M *.JPG /c "copy @file C:\SANDBOX\DIR02"

But it dumps out each time right away with a "File not found" message.

Thanks in advance for your help!

Upvotes: 0

Views: 1121

Answers (2)

Adam
Adam

Reputation: 1

This worked for me:

forfiles /s /p "C:\SourceFolder" /C "cmd /c copy @path C:\DestinationFolder"

Upvotes: 0

Aacini
Aacini

Reputation: 67226

Well, if we change "maintaining the most recent copy" by "copying only the modified files", then this command do that:

xcopy "C:\Base Files\*.*" C:\Backup /m /s

Regards...

Upvotes: 1

Related Questions