get around having to specify its a directory or file

D

djc

using xcopy like so:

xcopy c:\folder\file.txt c:\bakup\file.txt

prompts me to specify if destination is a folder or file. I can do this:

echo f | xcopy c:\folder\file.txt c:\bakup\file.txt

to get around it in a batch file but somehow I thing there is an
easier/better way I'm not aware of? This is for a one file copy... uhh.. did
I just answer my own question? I should use copy instead of xcopy in this
case?

any info is appreciated. Thanks.
 
G

Gary Smith

djc said:
using xcopy like so:
xcopy c:\folder\file.txt c:\bakup\file.txt
prompts me to specify if destination is a folder or file. I can do this:
echo f | xcopy c:\folder\file.txt c:\bakup\file.txt
to get around it in a batch file but somehow I thing there is an
easier/better way I'm not aware of? This is for a one file copy... uhh.. did
I just answer my own question? I should use copy instead of xcopy in this
case?

There's nothing wrong with the "echo f" approach, but if you intend to
keep the filename the same, "c:\folder\file.txt c:\bakup\" works nicely.
 
D

djc

the only answer I found in xcopy /? looked like it was only for when copying
multiple files? maybe I missed something or misunderstood that one.

thanks for the info.

Yes you did and another answer is in
xcopy /?
 
D

djc

thanks. Has it always been that way from dos/9x through xp? I always find
myself having to play around with these things when I need them.

thanks agian.
 
D

djc

another quick ?

has the behavior mentioned in my original post (promting for whether dest is
a file or directory) been that way from dos/9x through xp? In other words,
if I'm using echo f | xcopy ..etc.. will it bomb on another windows version?

thanks all.
 
J

John Zeman

thanks. Has it always been that way from dos/9x through xp? I always find
myself having to play around with these things when I need them.

thanks agian.


Has it always been that way from dos/9x through xp?

Yes. For a good explanation why this is you might want to read the article
at the following link:

http://www.xxcopy.com/xxcopy22.htm

It was written by the author of xxcopy (that's not a typo, xxcopy is like
xcopy only many times more powerful).

John
 
G

Gary Smith

djc said:
has the behavior mentioned in my original post (promting for whether dest is
a file or directory) been that way from dos/9x through xp? In other words,
if I'm using echo f | xcopy ..etc.. will it bomb on another windows version?

So far as I konw, that technique will work on all versions of xcopy. Of
course if the file alreasy exists, xcopy will ask whether you want it
overwrite it, and will expect "y" or "n" rather than "f". If that's a
possibility, you should probably check for the existence of the file
before attempting the copy.
 
G

guard

djc said:
using xcopy like so:

xcopy c:\folder\file.txt c:\bakup\file.txt

prompts me to specify if destination is a folder or file. I can do this:

echo f | xcopy c:\folder\file.txt c:\bakup\file.txt

to get around it in a batch file but somehow I thing there is an
easier/better way I'm not aware of? This is for a one file copy... uhh.. did
I just answer my own question? I should use copy instead of xcopy in this
case?

any info is appreciated. Thanks.

See the Xcopy page at
(http://TheSystemGuard.com/TheGuardBook/CCS-Ext/XCopy.htm)

for cross-platform syntax (NT/2K/XP/K3).

-tsg

/-----------------+---------------+----------------------\
| COMPATIBILITY | CLARITY | SPEED |
| Write code ONCE | Make it clear | THEN...Make it fast! |
\-----------------+---------------+----------------------/
400+ command-line resources using ONLY native NT commands!
(http://TheSystemGuard.com/default.asp#MasterCommandList)
 

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