8

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

2 Answers 2

15

Try

xcopy "C:\Documents and Settings\follag\Desktop\Music" "\PC NAME\c$\Documents and Settings\All Users\Desktop\Music" /E /I
Sign up to request clarification or add additional context in comments.

6 Comments

Perfect! Worked like a charm. Thanks for the help.
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
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*.*" /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 /Q
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 /Q The files are copying but the folders and files in "New Music" are remaining.
Had a typo in this: DEL "C:\Documents and Settings\follag\Desktop\New Music*.*" /Q Forgot the slash between New Music and .. The "For /f"... should be on a separate line.
|
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.