3

I need to copy a file C:\plst.m3u into all subfolders of C:\Music. I'm using this command:

FOR /R "C:\Music" %G IN (.) DO xcopy "C:\plst.m3u" %G

It works, but only for the paths, which doesn't contain spaces.

So, in the path C:\Music\AB\, it successfully creates plst.m3u in the AB folder. But for the path C:\Music\A B\ it returns error: invalid number of parameters

Here, I'm out of ideas. Any suggestions?

1 Answer 1

2

You need to wrap the %G in xcopy otherwise it will pass b\ as part of the xcopy command

Example:

FOR /R "C:\Music" %G IN (.) DO xcopy "C:\plst.m3u" "%G"


Why does this occur?

The command that is passed is DO xcopy "C:\plst.m3u" C:\Music\A B\ as there is no wrapping around the %G in the output

Because there is a space there it tries to pass the b\ as part of the xcopy. Available switches for xcopy:

XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W]
                           [/C] [/I] [/Q] [/F] [/L] [/G] [/H] [/R] [/T] [/U]
                           [/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z] [/B]
                           [/EXCLUDE:file1[+file2][+file3]...]

As b\ is not a part of these switches it returns the error invalid number of parameters

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .