using /exclude: in xcopy

  • Thread starter Thread starter Jim Curran
  • Start date Start date
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?
 
You can not use spaces in a batch command unless you enclose them in quotes.

"\\jcurran\C\$NSWork\Admin\Computer Network Setup\exclude.txt"
 
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"
 
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
 
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.
 
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.
 
Back
Top