?
Solved

using xcopy, but excluding one directory

Posted on 2004-04-02
7
Medium Priority
?
6,022 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

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 800 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

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

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…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

719 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