Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hey! I'm new to xcopy but i get the overall idea. I've been keeping my script simple, what my script does is a copy of important files on my computer to another computer on the network incase one crashes or whatever. Most of the script worked fine except for the exclusion of files and some lines just didn't work without reason!
One of my lines in this batch file was-
xcopy "C:\Program Files\Macromedia" "H:\Gilpo Backup\Program Files\Macromedia" /I
This didn't work yet i wrote my other lines like that and they did work, after the line above i got '0 File(s) copied'
I also got an error like this one below for a different line:
C:\Documents and Settings\Blayne\Desktop>xcopy "C:\Program Files\Maxis\SimCity 3
000\Cities\StarterTowns\*sc3 "H:\Gilpo Backup\Program Files\Maxis\SimCity 3000\C
ities\StarterTowns" /I
Parse ErrorOnce again I can't find the problem, and last but not least the major one that I just can't get!!! I've checked sooo many websites and forums here but I just didn't get it.
xcopy "C:\Documents and Settings\Blayne\My Documents" "H:\Gilpo Backup\Blayne" /I /exclude:"\Unreal Tournament\"+\Incomplete\+\KaZaA\+\MGI\
I got an error saying 'Can't read file: "\Unreal Tournament\"'
That didn't work but i also tried on top of that another method-
xcopy "C:\Documents and Settings\Blayne\My Documents" "H:\Gilpo Backup\Blayne" /I /exclude:"C:\Documents and Settings\Blayne\Desktop\exclude1.txt"
In the exclude1.txt file i had the following lines-
"C:\Documents and Settings\Blayne\My Documents\Unreal Tournament\"
"C:\Documents and Settings\Blayne\My Documents\Incomplete\"
"C:\Documents and Settings\Blayne\My Documents\KaZaA\"
"C:\Documents and Settings\Blayne\My Documents\MGI\"None of these methods have worked and I'm only very new to all this so could someone please help me it would be appreciated very much.
Thnx

xcopy "C:\Program Files\Macromedia" "H:\Gilpo Backup\Program Files\Macromedia" /I
Maybe try putting an ending \* when dealing with directories. For example: xcopy "C:\Program Files\Macromedia\*" "H:\Gilpo Backup\Program Files\Macromedia" /I
xcopy "C:\Program Files\Maxis\SimCity 3
000\Cities\StarterTowns\*.sc3" "H:\Gilpo Backup\Program Files\Maxis\SimCity 3000\C
ities\StarterTowns" /IYou got a parse error because it couldn't parse the input (duh :). You're missing a quote and you should really have a dot between the * and the sc3 (both highlighted above).
To exclude things, try not using the complete paths, and you need leading slashes. For example, your exclude file might look like:
\My Documents\Unreal Tournament\
\My Documents\Incomplete\
\My Documents\KaZaA\
\My Documents\MGI\Also, on these you probably want to use a couple more switches if it's being used to backup files. You may want to use:
/E - copy all subfolders
/Y - don't prompt to overwrite older files
/C - continue copying after error
/V - verify files after copy
/R - overwrite read-only files
/Z - copy in restartable modeTry some of these and see if they help.

Dr. Nick,
Thanks heaps I'd overlooked the parse error (silly me, sorry), I didn't know about the '*.sc3' that really helped thanks. I tried the "...\macromedia\*" but unfortunatly it still says '0 Files copied.' I changed the exclude to like u said /exclude:"C:\Documents and Settings\Blayne\Desktop\exclude1.txt" but i still get the error 'Can't read file "C:\Documents and Settings\Blayne\Desktop\exclude1.txt"In the exclude1.txt I put in what you said-
\My Documents\Unreal Tournament\
\My Documents\Incomplete\
\My Documents\KaZaA\
\My Documents\MGI\I've tried with and without quotation marks. It isn't working though because it can't read the file as I said above. The macromedia one I haven no clue at all, it just won't copy files.

Hey Dr Nick and anyone else reading. I needed the /E for the macromedia folder. Thanks :), as you can see i'm new to this lol. The exclude thing is about the only thing not working now so if anyone could help with that please read my post above. Also just wondering is there a way to apply your switches to every line in you r script without writing the switches on each sepearte line?
Thanks guys, especially you Dr Nick!

I am running into the same issue. I am trying to write a vbscript to perform a xcopy and copy files from my dev server to the QA server and I do not want the uploads folder where we store user upload documents to be overwritten...I cant seem to get the exclude switch working at all. here is xcopy command I am trying to use
xcopy \\dev\appfolder \\qa\appfolder /E/Y/Exclude:"exclude.txt"
And I get the error Can't read file: exclude.txt
I checked if this had to do with permissions on this file in my C: drive, but the file has full control for everyone. Any help will be great

I guess I have figured out a way to work with exclude
C:\>xcopy \\dev\appfolder /Exclude:exclude_folder.txt \\qa\appfolder /E/Y
This command worked!

Hey Prat,
Ok here's what you do for your problem. The following worked for me and the crucial key is that you can't have spaces in your directory name for the exclude text file. I tried with "speach marks" but it just doesn't work. The following worked for me though---xcopy "C:\Documents and Settings\Blayne\My Documents" "H:\Gilpo Backup\Blayne" /I /E /Y /C /V /R /Z /K /H /exclude:C:\Backupexclude\exclude1.txt
That's straight out of my script. In the exclude1.txt i have things like...
\My Documents\MGI\
\My Documents\Music\Just change it to suite you and it works provided you don't have any spaces in the exclude directory:
/exclude:C:\Backupexclude\exclude1.txt
No spaces for C:\Backupexclude\exclude1.txt
If you had C:\Backup exclude\exclude1.txt it wouldn't work. Pretty silly if you ask me but that's the probelm. Also in your txt document rather than putting things like:
\Music\
It's better to add a folder or more before so...
\My Documents\Music\
Note: remember to have a slash after your last folder in this case '\Music\' not '\Music'
Hope this helps =)
Black Ice

Hi,
I got two hard drives in my machine. I want to copy all files of an old drive (C: drive) to a new drive. So when the old drive (C: drive) is not working, I can plug into the new drive and working on the new drive. I am using xcopy commands in windows 2000 safe mode. I have not installed the Ghost program. So I use the xcopy commands.Why the exclue pamater notworking?student always learning

Basically, I want to copy all files on C: drive to new hard drive (E:) I use the command: xcopy C: E: /s /e /h /exclude: System Volume Information. The error message is "Invalid number of parameters"
I much appreciate the helpstudent always learning

Some things of note about xcopy:
- In reply to 'student', /EXCLUDE does not support filenames with spaces, in any form. I've tried quoting them singly, doubly, quoting the whole argument, etc. -- the only way I've found to use an exclude file with spaces in its pathname is to use the old 8.3 name for it:
won't work: /EXCLUDE:"C:\Documents and Settings\Me\exclude.txt"
works: /EXCLUDE:C:\Docume~1\Me\exclude.txt
- As alluded to by Dr. Nick, xcopy's /? documentation is wrong when it says:/EXCLUDE:file1[+file2][+file3]...
... 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. ...It should probably say *relative* path, because that's what happens. For example, suppose my exclusions file contains the line
C:\Documents and Settings\Me\Start Menu
and I invoke xcopy from "C:\Documents and Settings\Me\" with a source argument of "*". xcopy will copy the Start Menu folder because "C:\Documents and Settings\Me\Start Menu" is not a substring of "Start Menu\".
However, if I were to invoke xcopy with a source argument of "C:\Documents and Settings\Me", xcopy uses the full absolute paths to match against my exclusion list, and now indeed "C:\Documents and Settings\Me\Start Menu" is a substring of "C:\Documents and Settings\Me\Start Menu".
- (not really related to this post, but whatever) When using the /m option (copy only files with Archive, then clear Archive), xcopy does not clear the archive bits until after *all* files are done copying. This can be handy, e.g. you're in the middle of a backup and you notice your exclusions file isn't working.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |