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\
pauseThen I changed the batch and get this error: "File not found - Desktop"
xcopy /s/z D:\...\%username%\Desktop C:\SomeRandomFolder\
pauseHow do I fix these errors?
02 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