xcopy

  • Thread starter Thread starter capitan
  • Start date Start date
C

capitan

Testing out xcopy in a batch file on windows xp sp2, I have the below
command, and when I run this cmd file, it gives me the message "File not
found - *.*"

xcopy "C:\Documents and settings\%username\Favorites\*.*" >nul
V:\%username%\favorites /s /Y

Is there some reason the command prompt doesn't recognize the wildcard?
I have also tried it without the wildcard, with only *, both with the
trailing \ and without, but can't seem to get it to work.

Thanks for all help!
 
capitan said:
Testing out xcopy in a batch file on windows xp sp2, I have the below
command, and when I run this cmd file, it gives me the message "File not
found - *.*"

xcopy "C:\Documents and settings\%username\Favorites\*.*" >nul
V:\%username%\favorites /s /Y

Is there some reason the command prompt doesn't recognize the wildcard?
I have also tried it without the wildcard, with only *, both with the
trailing \ and without, but can't seem to get it to work.

Thanks for all help!
Hi,

Use "%username%" instead of "%username" maybe?

But even better would be to use:
"%USERPROFILE%\Favorites\*.*"

Never use username to get a user's profile path, because sometimes the
user profile path contains more than just the username (e.g.
<username>.<domain>, <username>.000, <username>.windows).
 
capitan said:
Testing out xcopy in a batch file on windows xp sp2, I have
the below command, and when I run this cmd file, it gives me
the message "File not found - *.*"

xcopy "C:\Documents and settings\%username\Favorites\*.*"

Is there some reason the command prompt doesn't recognize
the wildcard? I have also tried it without the wildcard,
with only *, both with the trailing \ and without, but can't
seem to get it to work.
Thanks for all help!

You left out a % sign. It should be this:

xcopy "C:\Documents and settings\%username%\Favorites\*.*" nul
V:\%username%\favorites /s /Y

Nepatsfan
 
try this instead

xcopy "C:\Documents and settings\%username%\Favorites\*.*" >nul
V:\%username%\favorites\*.* /s /Y
 
Try;
xcopy "C:\Documents and settings\%username%\Favorites\*.*"
V:\%username%\favorites /s /Y
or
xcopy %userprofile%\Favorites\*.* V:\%username%\favorites /s /Y

instead of
xcopy "C:\Documents and settings\%username\Favorites\*.*"
V:\%username%\favorites /s /Y

also make sure the destination directory exists ahead of time.

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect
 
Torgeir said:
Hi,

Use "%username%" instead of "%username" maybe?

But even better would be to use:
"%USERPROFILE%\Favorites\*.*"

Never use username to get a user's profile path, because sometimes the
user profile path contains more than just the username (e.g.
<username>.<domain>, <username>.000, <username>.windows).

Thanks Torgeir and Nepatsfan, it works like a charm now. :)
 
C:\Program Files\Support Tools>xcopy "C:\Documents and settings\%username%\Favor
ites\*.*" "V:\%username%\favorites\*.*" /s /Y >nul

Come on people there were multiple errors in it.
 
Back
Top