Reputation: 747
I'm trying to make a batch file that makes a backup of the USB stick that it is on, and places the copies of the USB files on the computer. It should do a few things:
>>Make copies of all files and folders on the USB
>>Reside on the top level of the USB stick (not in any folders)
>>Nor should all the other files/folders have to reside in a folder
(which would be used to just copy that folder)
>>Automatically chooses to overwrite any files that will be replaced
I tried to do this using XCOPY, although I ran into some problems. First, I'm not sure how to make the batch file copy all files from drive x. The USB may be plugged into the computer and be listed as drive G, H, E, X, Y, Z, whatever. So I can't just do
XCOPY "G:" "C:\Users\Backup" (usually I add /E and /I parameters)
The second issue with this approach is that I don't think there's any parameter which allows you to choose an automatic "overwrite all". It used to exist, but I think only in Win 2000.
I'm not very knowledgable about CMD, I've just used it occasionally to make other backup batch files, so I'm hoping someone here knows a way to overcome these obstacles.
Thank you for any help,
AJ
Upvotes: 0
Views: 3041
Reputation: 4799
I have a detailed explanation of my backup batch file that resides in the root of all my pen drives on my blog here: http://www.scotthelme.co.uk/blog/backing-up-your-usb-drives/
Let me know if it helps.
Upvotes: 1
Reputation: 223207
Use /Y with xcopy
/Y Suppresses prompting to confirm you want to overwrite an existing destination file.
Type xcopy /?
to view all the available switches
EDIT: Here is thread discussing finding USB drive letter. Give it a shot, may be its helpful.
Upvotes: 2