xcopy

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!
 
T

Torgeir Bakken \(MVP\)

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).
 
N

Nepatsfan

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
 
B

Bob I

try this instead

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

Dave Patrick

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
 
C

capitan

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. :)
 
D

David Candy

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top