Computing.Net > Forums > Programming > Copy Paste Files and Folder

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Copy Paste Files and Folder

Reply to Message Icon

Name: AlwaysWillingToLearn
Date: October 15, 2009 at 05:58:55 Pacific
OS: Microsoft Windows XP Professional
CPU/Ram: 3 GHz / 3582 MB
Product: Gigabyte / P35c-ds3r
Subcategory: Batch
Comment:

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.



Sponsored Link
Ads by Google

Response Number 1
Name: AlwaysWillingToLearn
Date: October 15, 2009 at 06:02:47 Pacific
Reply:

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,


0

Response Number 2
Name: Razor2.3
Date: October 15, 2009 at 06:35:41 Pacific
Reply:

You need to use double quotes around the individual paths

xcopy "k:\documents and settings\my documents\bunty\my videos" "f:\temp" /e


1

Response Number 3
Name: Mechanix2Go
Date: October 15, 2009 at 06:35:57 Pacific
Reply:

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


0

Response Number 4
Name: AlwaysWillingToLearn
Date: October 15, 2009 at 06:46:17 Pacific
Reply:

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,


0

Response Number 5
Name: Mechanix2Go
Date: October 15, 2009 at 06:50:27 Pacific
Reply:

We're left wondering what it's churning away at.


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

M2


0

Related Posts

See More



Response Number 6
Name: AlwaysWillingToLearn
Date: October 15, 2009 at 06:54:35 Pacific
Reply:

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,


0

Response Number 7
Name: Mechanix2Go
Date: October 15, 2009 at 07:05:41 Pacific
Reply:

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


0

Response Number 8
Name: AlwaysWillingToLearn
Date: October 15, 2009 at 07:13:49 Pacific
Reply:

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,


0

Response Number 9
Name: Mechanix2Go
Date: October 15, 2009 at 07:23:28 Pacific
Reply:

set /p f=file type ?

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


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

M2


1

Response Number 10
Name: AlwaysWillingToLearn
Date: October 15, 2009 at 07:39:18 Pacific
Reply:

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,


0

Response Number 11
Name: Mechanix2Go
Date: October 15, 2009 at 07:48:01 Pacific
Reply:

"nothing happens"

Lemme guess. You're not at a prompt.


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

M2


0

Response Number 12
Name: Razor2.3
Date: October 15, 2009 at 07:55:34 Pacific
Reply:

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


0

Response Number 13
Name: AlwaysWillingToLearn
Date: October 15, 2009 at 07:58:13 Pacific
Reply:

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,


0

Response Number 14
Name: AlwaysWillingToLearn
Date: October 15, 2009 at 08:09:53 Pacific
Reply:

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.


0

Response Number 15
Name: Razor2.3
Date: October 15, 2009 at 08:32:13 Pacific
Reply:

. . . And now I'm sad.

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


0

Response Number 16
Name: AlwaysWillingToLearn
Date: October 15, 2009 at 09:28:29 Pacific
Reply:

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


0

Response Number 17
Name: AlwaysWillingToLearn
Date: October 15, 2009 at 10:28:46 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon





Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: Copy Paste Files and Folder

Enumerate all files and folders www.computing.net/answers/programming/enumerate-all-files-and-folders/9618.html

hiding picture files and folders www.computing.net/answers/programming/hiding-picture-files-and-folders/3886.html

rename files and folder to lowercase with b www.computing.net/answers/programming/rename-files-and-folder-to-lowercase-with-b/19161.html