Command line code to copy folders

I have been researching xcopy and trying to find a command line tool that will correctly copy files from a networked pc to a local pc. I wish to write a script later on, but the code Ive tried keeps giving me "Invalid number of parameters".

What Ive tried, is "xcopy /s \\computername\firstfolder\secondfolder D:\firstfolder\secondfolder"

Oddly enough, "xcopy /s \\computername\firstfolder D:\firstfolder" works.

This is on a computer which is my media system and I wish to have a script at bootup that will auto-transfer the files. It works for one folder deep on both sides, but not 2, as in what I have above.

Do I need mapped drives instead? Or do I need to use robocopy?
Thoughts anyone?
Thanks,
Jim
 
Use the E switch.

xcopy /s /e \\computername\firstfolder\secondfolder D:\firstfolder\secondfolder

The E switch copies subfolders, even if they are empty.
 
Have you tried:

xcopy \\computername\firstfolder\secondfolder D:\firstfolder\secondfolder /s /e
 
the target folder is just that; a TARGET

however, the source folder becomes a list of files IN THAT FOLDER
so if the number of files therein is high, then your symptom is the result.

You need a script that has the concept of Foreach
Code:
foreach fn in dir {
    xcopy fn targetDir/
}
Perl & PHP both provide this construct
 
When working with filenames with spaces put them inside quotes.
xcopy /s "\\source1\dir 1\dir 2" "C:\temp\tmp 123"
 
When working with filenames with spaces put them inside quotes.
xcopy /s "\\source1\dir 1\dir 2" "C:\temp\tmp 123"

When I put them in quotes, it comes back saying "Invalid path 0 File(s) copied".
What I have been working with is the following:
"xcopy /s "\\Production\TV Shows\Mike and Molly\ D:\TV Shows\Mike and
Molly\" "

So what would be missing here?
 
What I have been working with is the following:
"xcopy /s "\\Production\TV Shows\Mike and Molly\ D:\TV Shows\Mike and
Molly\" "

I've always used this
Code:
"xcopy /s \\Production\"TV Shows"\"Mike and Molly"\  D:\"TV Shows"\"Mike and Molly"\
but this is still exposed for two issues:
1) too many files in the source directory
2) file names with embedded spaces
 
I ended up having remove one of the folders in the path on the source computer, now it will run. I can write my script now.
Thanks.
 
When I put them in quotes, it comes back saying "Invalid path 0 File(s) copied".
What I have been working with is the following:
"xcopy /s "\\Production\TV Shows\Mike and Molly\ D:\TV Shows\Mike and
Molly\" "

So what would be missing here?

Enclose the source and destination with each own separate quotes. The same with my example.
"xcopy /s "\\Production\TV Shows\Mike and Molly\" "D:\TV Shows\Mike and Molly\" "
 
Back