Solved

using xcopy, but excluding one directory

Posted on 2004-04-02
7
6,020 Views
Last Modified: 2007-12-19
I have a batch script where I want to xcopy the contents of my Y drive to my X drive, but I want to exclude Y:\FremontTCM, which is a directory with a bunch of subdirectories and files.  The following command:

xcopy  /e /exclude:y:\fremonttcm y:\* x:\*

does not work.  I know that the /exclude must have a filename to read from.  What do I need to do here to get this to work?
Thanks!

0
Comment
Question by:texasreddog
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 32

Expert Comment

by:LucF
ID: 10741533
Hi texasreddog,

Almost right, you just need to add one backslash:
> xcopy  /e /exclude:y:\fremonttcm\ y:\* x:\*


Greetings,

LucF
0
 

Author Comment

by:texasreddog
ID: 10741576
I tried running the command, and I get this.  It's still looking for a file.
By the way, both x:\ and y:\ are mapped network drives, if that is causing a problem.

C:\tcm>xcopy  /e /exclude:y:\fremonttcm\ y:\* x:\*
Can't read file: y:\fremonttcm\

0 File(s) copied
0
 
LVL 32

Expert Comment

by:LucF
ID: 10741667
ah... have you tried:

xcopy y:\* x:\* /e /exclude:y:\fremonttcm\
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 

Author Comment

by:texasreddog
ID: 10741726
I tried that, but no luck.  When I put

y:\fremonttcm\

into a text file called excludefremont.txt, then ran:

xcopy y:\* x:\* /e /exclude:excludefremont.txt

then that runs.  So apparently, the only way xcopy will work is to put the excludes into a text file.  You can't run it by specifying your excludes on the command line.  Correct me if I'm wrong.
0
 
LVL 20

Accepted Solution

by:
Dufo G. Belski earned 200 total points
ID: 10741811
I've been following this thread with interest.  xcopy /? is very confusing about the exclude syntax.  This link makes it explicit that the /exclude switch *is* looking for a file containing strings to exclude.

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/xcopy.mspx

Who knew?
0
 

Expert Comment

by:sylkin
ID: 11026890
here's a good example:

http://www.ekho.com/Training_Videos/XCOPY_NOTES.pdf

you want to exclude a file which contains the files extensions that
you don't want:

xcopy drive_A_stuff  to_drive_B_stuff  /EXCLUDE:junk.txt

where junk.txt is:

.mp3
.zip
.etc...

(one extension per line)


Paul Blue
0
 

Expert Comment

by:sylkin
ID: 11028542
also, the EXCLUDE .txt file must be in the same directory as the .bat file
if you are just using "/EXCLUDE:junk.txt"

Blue
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question