Windows – Batch File to Copy Files Between Folders

batch filewindows

My scanner software puts it's file into YYYY_MM_DD subfolders in C:\Dokumente und Einstellungen\Enrico\Eigene Dateien\Eigene Bilder\MP Navigator EX. The files are all JPEG files.

Now I need to copy them out of the virtual machine, into a shared drive which is called E:.

I would like to copy the subfolders into the shared drive, so that I have those date folders there. If a new picture is added to today's folder, it should be copied as well.

On Linux, I would just use rsync -avE for this.

How can I do this with a plain batch file in XP and 7?

Best Answer

You can use xcopy to copy entire directories (including subdirectories).

The syntax is:

xcopy source destination /S

where the /S switch includes non-empty directories (/E copies empty directories as well).

There are a couple of switches that serve as a backup solution:

  • /M copies only changed files (archive attribute set) and unsets the attribute.

  • /D copies only those files whose source time is newer than the destination time.

Related Question