tags:

views:

351

answers:

2

Hi,

I have a folder with numerous files that I need to copy to multiple PCs on a network. I thought if the folder didn't exist it would automatically create it. Here's what I have...

copy "C:\Documents and Settings\follag\Desktop\Music" "\PC NAME\c$\Documents and Settings\All Users\Desktop\Music"

When I look at the destination PC, it is not creating the folder and copying the files. I'm new to this whole batch files and would appreciate any help.

Thanks,

Greg

+1  A: 

Try

xcopy "C:\Documents and Settings\follag\Desktop\Music" "\PC NAME\c$\Documents and Settings\All Users\Desktop\Music" /E /I
LittleBobbyTables
Perfect! Worked like a charm. Thanks for the help.
Greg
Great, glad it worked!
LittleBobbyTables
One more question if you don't mind. How do I delete all files and folders in a directory after copying? Here's what I have...xcopy "C:\Documents and Settings\follag\Desktop\New Music" "\\ehgsmOR1347-02\c$\Documents and Settings\All Users\Desktop\Music" /E /I xcopy "C:\Documents and Settings\follag\Desktop\New Music" "C:\Documents and Settings\follag\Desktop\Music" /E /I del /s /q dirToDelete "C:\Documents and Settings\follag\Desktop\New Music\*"So basically, I'm trying to delete all files and folders in the "New Music" folder after copying it the the "Music" on the PC.Thanks
Greg
This should delete all files in the main "New Music" directory, then delete any subfolders in the "New Music" directory, while leaving the main "New Music" directory intact.DEL "C:\Documents and Settings\follag\Desktop\New Music\*.*" /Qfor /f "delims=~~~" %%a in ('dir "C:\Documents and Settings\follag\Desktop\New Music" /B /W /A:D') do rmdir "C:\Documents and Settings\follag\Desktop\New Music\%%a" /S /Q
LittleBobbyTables
Didn't seem to work...xcopy "C:\Documents and Settings\follag\Desktop\New Music" "\\ehgsmOR1347-02\c$\Documents and Settings\All Users\Desktop\Music" /E /I xcopy "C:\Documents and Settings\follag\Desktop\New Music" "C:\Documents and Settings\follag\Desktop\Music" /E /I DEL "C:\Documents and Settings\follag\Desktop\New Music*.*" /Q for /f "delims=~~~" %%a in ('dir "C:\Documents and Settings\follag\Desktop\New Music" /B /W /A:D') do rmdir "C:\Documents and Settings\follag\Desktop\New Music\%%a" /S /QThe files are copying but the folders and files in "New Music" are remaining.
Greg
Had a typo in this:DEL "C:\Documents and Settings\follag\Desktop\New Music\*.*" /QForgot the slash between New Music and *.*. The "For /f"... should be on a separate line.
LittleBobbyTables
That was it! Thanks again for all your help. I really appreicate it.
Greg
A: 

You only have a single backslash at the start of your second argument instead of two. Don't know if that's just a typo when copying here to SO. If not, then there's your problem.

Joe Enos
Thanks for your response :)
Greg