Link to home
Start Free TrialLog in
Avatar of Andy Brown
Andy BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Copy / Xcopy - Need to copy specific files within folders

I have a file called DBStart.mdb, that has different versions stored within seperate subfolders on my D: drive (D:\DBSTart Master).  I need to copy all of these files into a new folder called "D:\DBSTart backup", with the folder structures still in tact.

I do need to automate this, which was why I was thinking of using the XCopy / Copy command, but cannot remember the syntax.

Thanks for any help.
Avatar of uescomp
uescomp
Flag of Afghanistan image

Probably something like:

xcopy "D:\DVSTart Master" "D:\DBStart backup" /e /c /h /r /y /z
Avatar of strivoli
Consider RoboCopy as well. Much better than xcopy/copy.
You may see the syntax of the all commands with the /? parameter, as in:

copy /?
xcopy /?
robocopy /?

I did the above and piped the output to a text file, then into a Word file, then a PDF, which is attached for you. Regards, Joe
copy-xcopy-robocopy-syntax.pdf
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of oBdA
oBdA

Use robocopy.exe; it's more robust than copy/xcopy. Basic command to use:
robocopy.exe "D:\DBStart Master" "D:\DBStart backup" DBStart.mdb /s /r:2 /w:2
Note that
- robocopy will by default only copy files that don't exist in the same version in the target yet, so if you run it several times, it will not re-copy the files already backed up.
- If you want your backup to look exactly like your source folder (that is, if you delete a file/folder in the source, it will be deleted in the backup folder again), add /mir to the options. Might ot might not be useful for automation, depending on your requirements.
- If you want a log file (useful for automation), add /tee /np /log+:"C:\Temp\DBStartBackup.log" /tee to the options. /np disables the progress indicator, otherwise the progress indicator fills the log with control characters.
robocopy comes with Windows since Vista/W2k8, for XP/W2k3, it's part of the Resource Kit:
Windows Server 2003 Resource Kit Tools
http://www.microsoft.com/downloads/details.aspx?FamilyID=9D467A69-57FF-4AE7-96EE-B18C4790CFFD&displaylang=en
Avatar of Andy Brown

ASKER

Thanks guys - the XCopy code was perfect.

Thank you.