Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

using xcopy, but excluding one directory

Posted on 2004-04-02
7
Medium Priority
?
6,025 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: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
Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

 

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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

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…
VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses
Course of the Month9 days, 16 hours left to enroll

927 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