/exclude switch in XCOPY

T

Trevor L.

I have set up a batch file to do backups from C: to F: (external disk)

One line in the file is:
C:\Windows\System32\Xcopy.exe "C:\Documents and Settings\Trevor\My
Documents\*.*" "F:\0 C_Backup\Documents and Settings\Trevor\My Documents" /D
/E /C /I /Q /H /R /K /Y
(This is all on one line)

But I want to exclude certain directories, which are rather volatile, or
some which are quite non-volatile.

The help command xcopy /? says
/EXCLUDE:file1[+file2][+file3]...
Specifies a list of files containing strings. Each string
should be in a separate line in the files. When any of the
strings match any part of the absolute path of the file to be
copied, that file will be excluded from being copied. For
example, specifying a string like \obj\ or .obj will exclude
all files underneath the directory obj or all files with the
.obj extension respectively.

How, for example, do I exclude My Received Files ?
Do I use /EXCLUDE:\"My Received Files"\ ?

My queries are:
Where do I put the \ delimiters to indicate a directory ?
Where do I put the " quotes to enclose a directory with blank spaces ?

And how do I also exclude, e.g. My Music which is not very volatile
Is it /EXCLUDE:\"My Received Files"\+\"My Music"\ ?

Or are all of these incorrect?
If so, what is the correct syntax?

One possibility seems to be that I set up a file say exclude.txt, containing
\"My Received Files"\
\"My Music"\

and use
/EXCLUDE:exclude.txt

But I am still not sure where to put the \ and "
 
K

Klaus Jorgensen

Trevor L. wrote :
I have set up a batch file to do backups from C: to F: (external disk)

One line in the file is:
C:\Windows\System32\Xcopy.exe "C:\Documents and Settings\Trevor\My
Documents\*.*" "F:\0 C_Backup\Documents and Settings\Trevor\My Documents" /D
/E /C /I /Q /H /R /K /Y
(This is all on one line)

But I want to exclude certain directories, which are rather volatile, or some
which are quite non-volatile.

The help command xcopy /? says
/EXCLUDE:file1[+file2][+file3]...
Specifies a list of files containing strings. Each string
should be in a separate line in the files. When any of the
strings match any part of the absolute path of the file to be
copied, that file will be excluded from being copied. For
example, specifying a string like \obj\ or .obj will exclude
all files underneath the directory obj or all files with the
.obj extension respectively.

How, for example, do I exclude My Received Files ?
Do I use /EXCLUDE:\"My Received Files"\ ?

No - insert the name of the directories to be excluded in a text file -
e.g.:

Add "\My Received Files\" to a text file called "excl.txt" and then
use:

xcopy "%USERPROFILE%\My Documents" "F:\Backup\My Documents"
/exclude:excl.txt




/klaus
 
T

Trevor L.

Klaus said:
No - insert the name of the directories to be excluded in a text file
- e.g.:

Add "\My Received Files\" to a text file called "excl.txt" and then
use:

xcopy "%USERPROFILE%\My Documents" "F:\Backup\My Documents"
/exclude:excl.txt

Klaus
Thank you.

I thought this might be the case. However, I also wasn't sure whether it
would be
"\My Received Files\"
OR
\"My Received Files"\

I will give the former a try.
 
K

Klaus Jorgensen

Trevor L. wrote :
Klaus
Thank you.

I thought this might be the case. However, I also wasn't sure whether it
would be
"\My Received Files\"
OR
\"My Received Files"\

I will give the former a try.

....forgot to mention - the quotation marks should not be used.
Also, if there are more than one occurence of the exclusion string in a
directory name, it will apply to all of them.

/klaus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top