Link to home
Create AccountLog in
Avatar of al4629740
al4629740Flag for United States of America

asked on

Backup script avoid My Music

I want to backup all in Mydocument on everyone's computer, so I wrote the following batch file:

xcopy "%userprofile%\My Documents\*.*"   "I:\Backup\"   /c/f/h/d/y/s/e

How can I rewrite this to copy all in My Documents but avoid the folder 'My Music'
Avatar of Farhan Kazi
Farhan Kazi
Flag of Australia image

You can use /EXCLUDE switch of XCOPY command.
Like:
@ECHO My Music >ExcludeList.txt
xcopy "%userprofile%\My Documents\*.*"   "I:\Backup\" /c/f/h/d/y/s/e /EXCLUDE:ExcludeList.txt

Open in new window

Sorry exclude list file should be in following format:

\My Music\
\My Videos\
\Any other folder\
@ECHO \My Music\>ExcludeList.txt
xcopy "%userprofile%\My Documents\*.*"   "I:\Backup\" /c/f/h/d/y/s/e /EXCLUDE:ExcludeList.txt

Open in new window

Avatar of al4629740

ASKER

Is this how I would do multiple folders?
@ECHO \My Music\>ExcludeList.txt
@ECHO \My Videos\>ExcludeList.txt
xcopy "%userprofile%\My Documents\*.*"   "I:\Backup\" /c/f/h/d/y/s/e /EXCLUDE:ExcludeList.txt
 

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Farhan Kazi
Farhan Kazi
Flag of Australia image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
So a third would look like this:
@ECHO \My Music\>ExcludeList.txt
@ECHO \My Videos\>>ExcludeList.txt
@ECHO \My Pictures\>>ExcludeList.txt
xcopy "%userprofile%\My Documents\*.*"   "I:\Backup\" /c/f/h/d/y/s/e /EXCLUDE:ExcludeList.txt
 

Open in new window

Yes, exactly