xcopy Option?

G

Gene Wirchenko

Dear Win7 Folk:

There seems to be an option missing in xcopy, but possibly, I am
overlooking it.

The documentation for the /i option states:
"If destination does not exist and copying more than one file, assumes
that destination must be a directory."

What I want is just like this but for file. IOW, I want an
option that behaves like:
"If destination does not exist and copying more than one file, assumes
that destination must be FILES."

I occasionally copy groups of files renaming them as I go. For
example:
xcopy *.html *.ht
I need to do this, because I have some utilities that only understand
8.3 filenames. This sets off xcopy's file/directory query.

I have kludged something by creating a file containing "f" and
attaching it to stdin:
xcopy ... <shortf.dat
but this is a kludge and would likely cause trouble if there were a
different prompt.

Ideally, this should work in Windows XP (which as some of you
know, I still use).

Sincerely,

Gene Wirchenko
 
R

Roger Mills

Dear Win7 Folk:

There seems to be an option missing in xcopy, but possibly, I am
overlooking it.

The documentation for the /i option states:
"If destination does not exist and copying more than one file, assumes
that destination must be a directory."

What I want is just like this but for file. IOW, I want an
option that behaves like:
"If destination does not exist and copying more than one file, assumes
that destination must be FILES."

I occasionally copy groups of files renaming them as I go. For
example:
xcopy *.html *.ht
I need to do this, because I have some utilities that only understand
8.3 filenames. This sets off xcopy's file/directory query.

I have kludged something by creating a file containing "f" and
attaching it to stdin:
xcopy ...<shortf.dat
but this is a kludge and would likely cause trouble if there were a
different prompt.

Ideally, this should work in Windows XP (which as some of you
know, I still use).

Sincerely,

Gene Wirchenko

Have you tried xxcopy? This is a free (for personal use) third-party
application, which is like xcopy with a lot more bells and whistles. I
don't know whether it does exactly what you want, but it stands a good
chance.
--
Cheers,
Roger
____________
Please reply to Newsgroup. Whilst email address is valid, it is seldom
checked.
 
G

Gene E. Bloch

Dear Win7 Folk:

There seems to be an option missing in xcopy, but possibly, I am
overlooking it.

The documentation for the /i option states:
"If destination does not exist and copying more than one file, assumes
that destination must be a directory."

What I want is just like this but for file. IOW, I want an
option that behaves like:
"If destination does not exist and copying more than one file, assumes
that destination must be FILES."

I occasionally copy groups of files renaming them as I go. For
example:
xcopy *.html *.ht
I need to do this, because I have some utilities that only understand
8.3 filenames. This sets off xcopy's file/directory query.

I have kludged something by creating a file containing "f" and
attaching it to stdin:
xcopy ... <shortf.dat
but this is a kludge and would likely cause trouble if there were a
different prompt.

Ideally, this should work in Windows XP (which as some of you
know, I still use).

Sincerely,

Gene Wirchenko
I suspect that it means "if the destination name on the command line
doesn't exist...".

But notice the switches /L and /U, and maybe /N.
 
R

Roger Mills

Have you tried

xcopy *.html ..\*.htm
I want the two versions in the same directory.

[snip]

Sincerely,

Gene Wirchenko
That's not a problem - just omit the backslash!
--
Cheers,
Roger
____________
Please reply to Newsgroup. Whilst email address is valid, it is seldom
checked.
 
G

Gene Wirchenko

That's not a problem - just omit the backslash!
That does not work. It replaces the first two characters of the
filename with two periods.

But that got me thinking. I tried
xcopy *.html .\*.htm
and that worked. I assume that xcopy does something a bit different
with bare filenames (i.e., those without a path specified).

Sincerely,

Gene Wirchenko
 
R

Roger Mills

That does not work. It replaces the first two characters of the
filename with two periods.

But that got me thinking. I tried
xcopy *.html .\*.htm
and that worked. I assume that xcopy does something a bit different
with bare filenames (i.e., those without a path specified).

Sincerely,

Gene Wirchenko
Sorry, I should have said omit the two dots and the backslash. I
actually carried out an experiment to verify it.

I created two files, gash1.htm and gash2.htm
Then I typed xcopy *.htm *.html

Then I typed DIR, and it displayed 4 files - gash1.htm, gash1.html,
gash2.htm and gash2.html
--
Cheers,
Roger
____________
Please reply to Newsgroup. Whilst email address is valid, it is seldom
checked.
 
G

Gene Wirchenko

[snip]
Sorry, I should have said omit the two dots and the backslash. I
actually carried out an experiment to verify it.

I created two files, gash1.htm and gash2.htm
Then I typed xcopy *.htm *.html
I am going the other way, .html to .htm.

Sometimes, I get the file/directory message.
Then I typed DIR, and it displayed 4 files - gash1.htm, gash1.html,
gash2.htm and gash2.html
Sorry. Part of my issue is that I want to delete the .htm files
first so that if I delete a .html, its .htm is gone. Windows will
delete my .html files when I do
del *.htm
I dislike this "helpfulness".

Sincerely,

Gene Wirchenko
 
G

Gene E. Bloch

[snip]
Sorry, I should have said omit the two dots and the backslash. I
actually carried out an experiment to verify it.

I created two files, gash1.htm and gash2.htm
Then I typed xcopy *.htm *.html
I am going the other way, .html to .htm.

Sometimes, I get the file/directory message.
Then I typed DIR, and it displayed 4 files - gash1.htm, gash1.html,
gash2.htm and gash2.html
Sorry. Part of my issue is that I want to delete the .htm files
first so that if I delete a .html, its .htm is gone. Windows will
delete my .html files when I do
del *.htm
I dislike this "helpfulness".

Sincerely,

Gene Wirchenko
Use a loop in a batch file.
 
G

Gene E. Bloch

[snip]
Sorry, I should have said omit the two dots and the backslash. I
actually carried out an experiment to verify it.

I created two files, gash1.htm and gash2.htm
Then I typed xcopy *.htm *.html
I am going the other way, .html to .htm.

Sometimes, I get the file/directory message.
Then I typed DIR, and it displayed 4 files - gash1.htm, gash1.html,
gash2.htm and gash2.html
Sorry. Part of my issue is that I want to delete the .htm files
first so that if I delete a .html, its .htm is gone. Windows will
delete my .html files when I do
del *.htm
I dislike this "helpfulness".

Sincerely,

Gene Wirchenko
Use a loop in a batch file.
Actually, don't. It acts the same as your command, but one file at a
time.
 
C

Char Jackson

[snip]
Sorry, I should have said omit the two dots and the backslash. I
actually carried out an experiment to verify it.

I created two files, gash1.htm and gash2.htm
Then I typed xcopy *.htm *.html
I am going the other way, .html to .htm.

Sometimes, I get the file/directory message.
Then I typed DIR, and it displayed 4 files - gash1.htm, gash1.html,
gash2.htm and gash2.html
Sorry. Part of my issue is that I want to delete the .htm files
first so that if I delete a .html, its .htm is gone. Windows will
delete my .html files when I do
del *.htm
I dislike this "helpfulness".
Are you required to use .htm and .html, or can you use other
extensions that would make it easier to differentiate one set of files
from another? Such as .htm and .htm.bak or simply .bak?
 
B

Bob I

[snip]
Sorry, I should have said omit the two dots and the backslash. I
actually carried out an experiment to verify it.

I created two files, gash1.htm and gash2.htm
Then I typed xcopy *.htm *.html
I am going the other way, .html to .htm.

Sometimes, I get the file/directory message.
Then I typed DIR, and it displayed 4 files - gash1.htm, gash1.html,
gash2.htm and gash2.html
Sorry. Part of my issue is that I want to delete the .htm files
first so that if I delete a .html, its .htm is gone. Windows will
delete my .html files when I do
del *.htm
I dislike this "helpfulness".
Sorry, was backward on the . vs ..

What you say you want to do in deleting files sounds rather confusing.
 
N

Nil

Sorry. Part of my issue is that I want to delete the .htm files
first so that if I delete a .html, its .htm is gone. Windows will
delete my .html files when I do
del *.htm
I dislike this "helpfulness".
I never knew that the built in DEL command behaved that way. That's not
good.

I use JPSoft's CMD replacement, TCC LE
(http://jpsoft.com/tccle-cmd-replacement.html) and it behaves in a more
sane way. You might consider it. The free version has been good enough
for me.
 
G

Gene E. Bloch

I never knew that the built in DEL command behaved that way. That's not
good.

I use JPSoft's CMD replacement, TCC LE
(http://jpsoft.com/tccle-cmd-replacement.html) and it behaves in a more
sane way. You might consider it. The free version has been good enough
for me.
It was definitely new to me as well, and it sucks :)

My experimentation revealed not only that cmd acts the way Wirchenko
said, but even putting the action into a loop to act on individual files
doesn't help.

I went a bit further and discovered the underlying problem is that dir
treats .htm and html as the same. As in dir *.htm prints the html files
too - but, oddly, not vice versa.

Ouch.

So thanks for the link to JPSoft's program. Although since I never
experienced this before, it's probably more important for the OP than
for me - or, for that matter, you as well...
 
G

Gene Wirchenko

[snip]
What you say you want to do in deleting files sounds rather confusing.
This is for backing data from another computer. My printer is
attached to the backup data computer. (The work computer is
disconnected from the backup data computer which is my main box, and
it is going to stay that way!) My printer program only understands
8+3 filenames so I need an 8+3 version of my .html files.

Sincerely,

Gene Wirchenko
 
G

Gene Wirchenko

[snip]
Are you required to use .htm and .html, or can you use other
extensions that would make it easier to differentiate one set of files
from another? Such as .htm and .htm.bak or simply .bak?
No. Instead of .htm, I have decided to use .ht. This kludge
works.

Sincerely,

Gene Wirchenko
 
N

Nil

I went a bit further and discovered the underlying problem is that
dir treats .htm and html as the same. As in dir *.htm prints the
html files too - but, oddly, not vice versa.
That's just bizarre. I can't believe MS let such a bug go on all this
time, especially one that could so easily result in unintended data
loss.
So thanks for the link to JPSoft's program. Although since I never
experienced this before, it's probably more important for the OP
than for me - or, for that matter, you as well...
I started with their 4DOS product back in the DOS and early Windows
days. I used to write lots of fancy batch files that took advantage of
its advanced featured. I don't do much of that any more, but I still
appreciate that TCC works better than CMD... especially after hearing
this horror story about DEL!
 
B

Bill Blanton

My experimentation revealed not only that cmd acts the way Wirchenko
said, but even putting the action into a loop to act on individual files
doesn't help.

I went a bit further and discovered the underlying problem is that dir
treats .htm and html as the same. As in dir *.htm prints the html files
too - but, oddly, not vice versa.

Ouch.
Probably because the short name of foo.html is FOO~1.HTM

Powershell's Remove-Item (alias DEL) is another alternative.
 

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