Link to home
Start Free TrialLog in
Avatar of Steve34
Steve34Flag for United States of America

asked on

Why wont this work in a .bat file?

Hi;

II'm on windows 2000

I'm trying to be a good boy by backing up my files everyday.

I'm trying to write a bat file to back up all of the crap in my  My Documenets directory.

I keep trying this command:
xcopy C:\Documents and Settings\srussel\My Documents B:\MyDocuments /S/Y


I keep getting the error message "invalid number of prarameters".

Why?

What can I do about it?

Steve
Avatar of Housenet
Housenet
Flag of Canada image

-You forgot the quotes because of the 8.3 rule.
-This works.. I tested it.
xcopy C:\"Documents and Settings\srussel\My Documents" B:\"MyDocuments" /S/Y

ASKER CERTIFIED SOLUTION
Avatar of AvonWyss
AvonWyss
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Argh, shouldn't write such long explanations, this makes my answers late all the time... :-/
hahahah! Woo hoo :) nanannana
Housenet, I'll mail one of your colleagues to pour some glue in your keyboard... ;-)
And btw., this has nothing to do with the 8.3 rule, but only with the spaces used as parameter delimiters. The one big excpetion is the command CD, which ALWAYS only takes one parameter and thus also allows directory names with spaces not to be enclosed with quotes.
AvonWyss the fact is, when you use an 8 character represtentation of the path it works, so I think my statement also applies..     cd docume~1
Housenet, let's fight over this... hehehe... ;-)

No, seriously. Of course your suggested example is correct. And it's also ture that the 8.3 names don't need any quotes, as they never have spaces in them.

Fact is, XCOPY complains about too many parameters because its parser (correctly) parsed the word "and" as second filename and afterwards did not expect any other parameters to follow other than switches.

As for 8.3 names, you cannot know guess the correct 8.3 name for a long name; instead of docume~1 (in your example), it could also be docum~15 - so its not possible to reliably substitute long names by 8.3 names in batch files.
-AvonWyss...whatever.. who cares ?
-Steve34 give the points to whomever solved your problem FIRST. :)
Avatar of Steve34

ASKER

Well, there were 2 correct answers to my question.

Your answer had more explanation and since it came only 2min later then the first correct answer I'll  give the points to you being that  you did more more by typing more of an explanation :)

Thanks to everyone for the speedy reply.

Steve
Thanks Steve!
-Steve34 you're a freaken ass...