Batch file to only copy new files from source to destination
9,706
The xcopy
utility will do what you want:
xcopy /s /d {source dir}\ {target dir}\
or:
xcopy /s /d {source dir}\*.PNG {target dir}\
The first example copies all files, while the second copies only .PNG
files.
Omit /s
if you want to copy a single directory, not whole tree.
Related videos on Youtube
Author by
Kevin Brekke
Updated on September 18, 2022Comments
-
Kevin Brekke almost 2 years
I am trying to create a batch file that copies only new files to another folder. I have .png files that come in through FTP at various times throughout the day. So I am looking for a .bat that I can run once a day that will only copy the new .png files and place them in the destination folder.
However, the destination folder is always empty. This is because the software I use auto fetches the .png files for processing. I have been manually moving these .png files over everyday.
-
user almost 9 yearsI can't tell what you are asking, here. Can you perhaps edit your question and provide an example flow from start to finish?
-
Chenmunka almost 9 yearsWhy don't you use Robocopy?
-
Kevin Brekke almost 9 yearsxcopy C:\Test1\ C:\Test2\ /d /s /r /y This is what i have so far, but it only if the same files are in the destination folder.
-
-
Kevin Brekke almost 9 yearsIs there a way to only copy new .png files? such as only copy the new .png files for each new day.
-
AFH almost 9 yearsThat's precisely what the commands do:
/d
specifies to copy only new and updated files. If you want to copy each day's files to a separate directory, you will need to add a date to the/d
(seexcopy /?
).