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.

Share:
9,706

Related videos on Youtube

Kevin Brekke
Author by

Kevin Brekke

Updated on September 18, 2022

Comments

  • Kevin Brekke
    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
      user almost 9 years
      I can't tell what you are asking, here. Can you perhaps edit your question and provide an example flow from start to finish?
    • Chenmunka
      Chenmunka almost 9 years
      Why don't you use Robocopy?
    • Kevin Brekke
      Kevin Brekke almost 9 years
      xcopy 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
    Kevin Brekke almost 9 years
    Is there a way to only copy new .png files? such as only copy the new .png files for each new day.
  • AFH
    AFH almost 9 years
    That'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 (see xcopy /?).