Copy Paste Files and Folder

Gigabyte / P35c-ds3r
October 15, 2009 at 05:58:55
Specs: Microsoft Windows XP Professional, 3 GHz / 3582 MB
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:\temp

at 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.


See More: Copy Paste Files and Folder

Report •


#1
October 15, 2009 at 06:02:47
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,


Report •

#2
October 15, 2009 at 06:35:41
You need to use double quotes around the individual paths
xcopy "k:\documents and settings\my documents\bunty\my videos" "f:\temp" /e


Report •

#3
October 15, 2009 at 06:35:57
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 felicity

M2


Report •

Related Solutions

#4
October 15, 2009 at 06:46:17
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,


Report •

#5
October 15, 2009 at 06:50:27
We're left wondering what it's churning away at.


=====================================
Helping others achieve escape felicity

M2


Report •

#6
October 15, 2009 at 06:54:35
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,


Report •

#7
October 15, 2009 at 07:05:41
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 felicity

M2


Report •

#8
October 15, 2009 at 07:13:49
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,


Report •

#9
October 15, 2009 at 07:23:28
set /p f=file type ?

xcopy "src\!f!" "dest\"


=====================================
Helping others achieve escape felicity

M2


Report •

#10
October 15, 2009 at 07:39:18
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,


Report •

#11
October 15, 2009 at 07:48:01
"nothing happens"

Lemme guess. You're not at a prompt.


=====================================
Helping others achieve escape felicity

M2


Report •

#12
October 15, 2009 at 07:55:34
Instead of !f!, go with %f%. Mechanix2Go is assuming delayed expansion is enabled, and it's probably not.

Report •

#13
October 15, 2009 at 07:58:13
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) copied

any clues?

thanks,


Report •

#14
October 15, 2009 at 08:09:53
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.


Report •

#15
October 15, 2009 at 08:32:13
. . . And now I'm sad.

EDIT: VVV I was talking more about the ignored post, really. VVV


Report •

#16
October 15, 2009 at 09:28:29
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..

Report •

#17
October 15, 2009 at 10:28:46
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


Report •


Ask Question