Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XCopy EXCLUDE: proper syntax??

Status
Not open for further replies.

merctwister

Technical User
Nov 12, 2005
27
US
How would I use xcopy to exclude all .bak files in a
folder.

I was in my folder that I wanted to copy.
I wanted to copy all the the files in my folder
C:\Data (except the .bak files) to another Folder C:\Backup

I tried this:

C:\Data>Xcopy *.* C:\Backup /h/r/exclude:*.bak

but it still copied the .bak files to the C:\Backup
folder...what did I do wrong???
 
From Windows XP help on Xcopy:

Using /exclude
(..)If any of the listed strings match any part of the absolute path of the file to be copied, that file is then excluded from the copying process. For example, if you specify the string "\Obj\", you exclude all files underneath the Obj directory. If you specify the string ".obj", you exclude all files with the .obj extension.

So, I think your command line should be
C:\Data>Xcopy *.* C:\Backup /h/r/exclude:.bak

===
Karlis
ECDL; MCSA
 
I must be doing something wrong. I tried that command:

C:\Data>Xcopy *.* C:\Backup /h/r/exclude:.bak

& I got message:
0 files copied
can't read .bak

any suggestions?
 
if you are copying from C:\Data to C:\Backup I think it's like this:

Code:
xcopy \Data \Backup /h /r /exclude:.bak

you don't need the drive letter unless it's on another drive. xcopy should also be the first command, before source and destination.


 
if that doesn't work try using the quotes around the string:

Code:
xcopy \Data \Backup /h /r /exclude: ".bak"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top