Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Why wont this work in a .bat file?

Posted on 2001-06-28
12
Medium Priority
?
152 Views
Last Modified: 2010-04-13
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
0
Comment
Question by:Steve34
[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
  • 6
  • 5
12 Comments
 
LVL 12

Expert Comment

by:Housenet
ID: 6236253
-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

0
 
LVL 14

Accepted Solution

by:
AvonWyss earned 800 total points
ID: 6236255
You need to enclose the paths with "" if they have spaces in it, so that XCOPY (and all other command-line commands, by the way) knows where a file name starts and ends. Spaces usually separate parameters, so if you don't use the quotes the command will assume a new parameter after every space.

In your case,

xcopy "C:\Documents and Settings\srussel\My Documents" B:\MyDocuments /S /Y

will work fine.
0
 
LVL 14

Expert Comment

by:AvonWyss
ID: 6236256
Argh, shouldn't write such long explanations, this makes my answers late all the time... :-/
0
Does Your Cloud Backup Use Blockchain Technology?

Blockchain technology has already revolutionized finance thanks to Bitcoin. Now it's disrupting other areas, including the realm of data protection. Learn how blockchain is now being used to authenticate backup files and keep them safe from hackers.

 
LVL 12

Expert Comment

by:Housenet
ID: 6236258
hahahah! Woo hoo :) nanannana
0
 
LVL 14

Expert Comment

by:AvonWyss
ID: 6236273
Housenet, I'll mail one of your colleagues to pour some glue in your keyboard... ;-)
0
 
LVL 14

Expert Comment

by:AvonWyss
ID: 6236277
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.
0
 
LVL 12

Expert Comment

by:Housenet
ID: 6236285
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
0
 
LVL 14

Expert Comment

by:AvonWyss
ID: 6236319
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.
0
 
LVL 12

Expert Comment

by:Housenet
ID: 6236322
-AvonWyss...whatever.. who cares ?
-Steve34 give the points to whomever solved your problem FIRST. :)
0
 

Author Comment

by:Steve34
ID: 6238004
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
0
 
LVL 14

Expert Comment

by:AvonWyss
ID: 6238171
Thanks Steve!
0
 
LVL 12

Expert Comment

by:Housenet
ID: 6238633
-Steve34 you're a freaken ass...

0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
Whoever said that “a picture is worth one thousand words” observed a fact that can dramatically affect your marketing success. Most people tend to learn visually, so many publishers commonly acknowledge the effectiveness of visual learning by using…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

715 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