using /exclude: in xcopy

J

Jim Curran

I'm trying to use:

xcopy \\bhunsaker\C\$NSWork\$Accounting
E:\bhunsaker\C\$NSWork\$Accounting\ /d/s/e/y/i/exclude:\\jc
urran\C\$NSWork\Admin\Computer Network Setup\exclude.txt

to exclude .xlk files when copying with xcopy

exclude.txt simply has ".xlk" without quotes in it.

This results in an error: "Invalid number of parameters"

Any thought on what I'm doing wrong?
 
S

SunSpot

You can not use spaces in a batch command unless you enclose them in quotes.

"\\jcurran\C\$NSWork\Admin\Computer Network Setup\exclude.txt"
 
H

Herb Martin

Jim Curran said:
I'm trying to use:

xcopy \\bhunsaker\C\$NSWork\$Accounting
E:\bhunsaker\C\$NSWork\$Accounting\ /d/s/e/y/i/exclude:\\jc
urran\C\$NSWork\Admin\Computer Network Setup\exclude.txt

to exclude .xlk files when copying with xcopy

exclude.txt simply has ".xlk" without quotes in it.

You didn't put the quotes arount tht long exclude: path with spaces
int it. So you get lots of "extra parameters".

Try something like:
/exclude:"\\jcurran\C\$NSWork\Admin\Computer Network Setup\exclude.txt"
 
P

Paul R. Sadowski

Paul R. Sadowski said:
copy \\jcurran\C\$NSWork\Admin\Computer Network Setup\exclude.txt
%temp%\xx19653.tmp

I gave a bad and broken example... I'll blame it on the heat. The temp file
should best be generated something like:

copy "\\jcurran\C\$NSWork\Admin\Computer Network Setup\exclude.txt"
XCE%RANDOM%.tmp

to prevent any accidental overwrites by another copy of the script running
at the same time. Also one can't use %TEMP% because of it's long pathname.

Therefore:
copy "\\jcurran\C\$NSWork\Admin\Computer Network Setup\exclude.txt"
XCE%RANDOM%.tmp

xcopy \\bhunsaker\C\$NSWork\$Accounting
E:\bhunsaker\C\$NSWork\$Accounting\ /d/s/e/y/i/exclude:XCE%RANDOM%.tmp

del XCE%RANDOM%.tmp
 
M

Mark V

Paul R. Sadowski wrote in
I gave a bad and broken example... I'll blame it on the heat. The
temp file should best be generated something like:

copy "\\jcurran\C\$NSWork\Admin\Computer Network
Setup\exclude.txt" XCE%RANDOM%.tmp

to prevent any accidental overwrites by another copy of the script
running at the same time. Also one can't use %TEMP% because of
it's long pathname.

Therefore:
copy "\\jcurran\C\$NSWork\Admin\Computer Network
Setup\exclude.txt" XCE%RANDOM%.tmp

xcopy \\bhunsaker\C\$NSWork\$Accounting
E:\bhunsaker\C\$NSWork\$Accounting\
/d/s/e/y/i/exclude:XCE%RANDOM%.tmp

del XCE%RANDOM%.tmp

What? Each use of %random% is, well, RANDOM
(Okay, pseudo-random :) )

I think that you'd need something like
SET RAND=%RANDOM%
them utilize the value of %RAND% thereafter within the entire
batchfile.
 
P

Paul R. Sadowski

Mark V said:
What? Each use of %random% is, well, RANDOM
(Okay, pseudo-random :) )

I think that you'd need something like
SET RAND=%RANDOM%
them utilize the value of %RAND% thereafter within the entire
batchfile.

Yep, you're right. Thanks for catching it. Like I said, it must be the heat.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top