Solved

using xcopy, but excluding one directory

Posted on 2004-04-02
7
6,003 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
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 32

Expert Comment

by:Luc Franken
Comment Utility
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
Comment Utility
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:Luc Franken
Comment Utility
ah... have you tried:

xcopy y:\* x:\* /e /exclude:y:\fremonttcm\
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:texasreddog
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

772 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now