Error in batch file to copy folder: 'Invalid number of parameters'

I am making a batch file in Windows XP to copy my folders I need to another folder on my PC. I am getting an error.

I get the error "Invalid number of parameters".

xcopy /s/z D:\Documents and Settings\%username%\Desktop C:\SomeRandomFolder\
xcopy /s/z D:\Documents and Settings\%username%\Favorites C:\SomeRandomFolder\
xcopy /s/z D:\Documents and Settings\%username%\Start Menu C:\SomeRandomFolder\
xcopy /s/z D:\Documents and Settings\%username%\My Documents C:\SomeRandomFolder\
xcopy /s/z D:\Documents and Settings\%username%\PrintHood C:\SomeRandomFolder\
xcopy /s/z D:\Documents and Settings\%username%\NetHood C:\SomeRandomFolder\
xcopy /s/z D:\Documents and Settings\%username%\Templates C:\SomeRandomFolder\
xcopy /s/z D:\Documents and Settings\%username%\Searches C:\SomeRandomFolder\
xcopy /s/z D:\Documents and Settings\%username%\Local Settings\Application Data\Microsoft\Outlook C:\SomeRandomFolder\
pause

Then I changed the batch and get this error: "File not found - Desktop"

xcopy /s/z D:\...\%username%\Desktop C:\SomeRandomFolder\
pause

How do I fix these errors?

0

2 Answers

You need quotes at least around the filenames or directories with spaces in them but the best is to quote the whole parameters to avoid other problems as suggested by Marcks Thomas in the comments:

xcopy /s/z "D:\Documents and Settings\%username%\Favorites" "C:\SomeRandomFolder\"

or in this particular case copying from a user home directory, as Phillip R. commented, to work on all windows versions (including other languages too) you can use:

xcopy /s/z "%userprofile%\<somefolder>" "C:\SomeRandomFolder\"
3

You need to put quotations around the directory path.

xcopy /s/z "D:\Documents and Settings\%username%\Desktop" "C:\SomeRandomFolder\"

It's giving you an error because there is a space in you directory path so it's seeing it as a new directory when it isn't and it can't find it.

0

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like