Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Name: AlwaysWillingToLearn
Hi all,
I am trying to write a batch file that will copy all files from one harddrive (specific folder) to another harddrive. Well i havent actually tried this as a batch file, rather in command prompt like this
xcopy [source] [destination] /e
the source folder is:
K:\documents and settings\my documents\bunty\my videos\the destination folder is:
f:\tempat command promp i typed
xcopy k:\documents and settings\my documents\bunty\my videos f:\temp /e
when i press enter it say
"incorrect number of parameters"Any ideas why this is please?
also is it ok to use the files line lengh as i have done above, or should i shorten it using the ~ symbol, can someone show me how please?
would this is easier achieved as a batch if so can you possibly show me how?
Thanks for the help.
Bunty.

Oh wow, i just put that into notepad saved as a bat file and it worked, guess i should have tried before asking the question.
So i guess the question remains why didnt it work at the command prompt?
Thanks,

You need to use double quotes around the individual paths
xcopy "k:\documents and settings\my documents\bunty\my videos" "f:\temp" /e

The question is why did it work as a bat? It needs quotes, regardless.
xcopy "k:\documents and settings\my documents\bunty\my videos" f:\temp\
=====================================
Helping others achieve escape felicityM2

Thank you Razor2.3 and Mechanix2Go,
Thats awesome, will give that a go too, it was working tho without the quotes, not sure why, its actually working right now as we speak its churning away, but i know you guys are excellent at this so will stop my batch file and amend it with your suggestion.
Thanks a lot. My second attempt at writing something in batch - im liking it :-)
Cheers,

We're left wondering what it's churning away at.
=====================================
Helping others achieve escape felicityM2

Well what i did was this
xcopy Z:\Functions\Bunty\*.pdf Z:\Functions\Bunty\A
And it is copying all the pdfs from the bunty folder to the A folder, its actually working, its placing the pdfs one by one into the folder.
its not picking up any of the other files just the pdfs as iv specified.
the batch is located in the A folder and i am runing it from there. It seems to be working.
Thanks,

Sure, but that's not what you said.
The source you posted has spaces in it.
xcopy requires exactly one source and one destination. As delimited by spaces.
=====================================
Helping others achieve escape felicityM2

Doh,
Your right, sorry still learning, the string i posted doesnt work, i modified it with the quotes and NOW it works. Sorry about the confusion i didnt realise the spaces before.
Thank you so much for the advice seems to be doing the trick perfectly now.
Is there a way to have a inputbox appear before the copy paste starts so that i can specify what type of file i want to move
eg:
enter type of file: *.doc
and then the code will automatically assign this to a variable and copy paste all doc files?
Thanks guys,

set /p f=file type ?
xcopy "src\!f!" "dest\"
=====================================
Helping others achieve escape felicityM2

Hi M2,
so here is what i am putting into the batch
set /p f=file type ?
xcopy "Z:\Functions\Bunty\!f!" "Z:\Functions\Bunty\A"
when i run it i get the following
Z:\Functions\Bunty\A>set /p f=file type ?
file type ?and i type in *.pdf press enter
nothing happens. I am doing something obviously wrong any ideas please?
thanks,

"nothing happens"
Lemme guess. You're not at a prompt.
=====================================
Helping others achieve escape felicityM2

Instead of !f!, go with %f%. Mechanix2Go is assuming delayed expansion is enabled, and it's probably not.

Lol im confused :(
Ok when i run the batch, the command prompt appears and i am asked for the file type. i enter .pdf and the prompt very quickly displays something (too quick for me to see) and then closes.
the pdfs are not copied over.
i am assuming, when i i run the batch and the command prompt appears, it shoud ask me for a file type, then i enter *.pdf and it should start to display the names of each pdf as it copies them over, like it does with the previous code you suggested earlier.
Can you give me a hint to what i need to do, or what i am doing incorrectly please?
i added pause at the end and i found that it says
File not found - !f!
0 File(s) copiedany clues?
thanks,

Done some reading on google and found that the !f! needed to be %f% and it worked great.
Nice one M2 your a genious this is working awesome.
Thanks,
Bunty :-) wooo.

Oh and thank you VERY VERY much Razor2.3 you know your help is always appreciated mate. Its all working like a charm.. Awesome help guys., thank you..

Oh Em Ge, take my word for it i would never intentionally ignore anyones help, i am sorry Razor i didnt refresh the page and then obviously didnt see your reply,. Hey atleast i showed some attempt at working on the problem myself :-) right???
Anyways dude thanks again and have a good day/night.
Bunty

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |