Copy question

M

Mike Hood

This seems really simple, but I can't readily find the answer on the Web...
I'm trying to copy files from ServerA to ServerB in a batchfile. I can't get
it to work with

copy \\ServerA\c$\file.fil \\ServerB\d$

but instead it seems that I need to map drives to the servers as appropriate
and then use their letters, eg

copy u:\file.fil v:\

Is this right?

Thanks!
 
J

Jerold Schulman

This seems really simple, but I can't readily find the answer on the Web...
I'm trying to copy files from ServerA to ServerB in a batchfile. I can't get
it to work with

copy \\ServerA\c$\file.fil \\ServerB\d$

but instead it seems that I need to map drives to the servers as appropriate
and then use their letters, eg

copy u:\file.fil v:\

Is this right?

Thanks!

No.

copy \\ServerA\c$\file.fil \\ServerB\d$\*.*

Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com
http://www.jsifaq.com
 
M

Mark V

In said:
This seems really simple, but I can't readily find the answer on
the Web... I'm trying to copy files from ServerA to ServerB in a
batchfile. I can't get it to work with

copy \\ServerA\c$\file.fil \\ServerB\d$

but instead it seems that I need to map drives to the servers as
appropriate and then use their letters, eg

copy u:\file.fil v:\

Aside from syntax, is this batch running under an account (Scheduled
perhaps) that has no network access? The error msg is _ ?
 
M

Mike Hood

Rewrote the batchfile and it's now working as I'd originally intended. I
don't know what I'd done last week - must be a typo I'd misssed, despite
checking. Sorry to have wasted your time!

BTW, it was under a full admin account with network access. Msg was "The
network path was not found."

Thanks anyway.
 
M

Mike Hood

Problem solved now (see earlier reply) - but, I beg to differ over the need
for the "\*.*" at the end.
 
W

William Allen

Problem solved now (see earlier reply) - but, I beg to differ over the need
for the "\*.*" at the end.

You would be unwise to omit the trailing \*.* from the destination
filespec in COPY-ing. If you make a habit of this omission, and the
destination folder happens not to exist (say, because of a typo in
its name), all the files specified in the source wildcard may be
concatenated in ASCII COPY mode to a single destination file
(assigned with the folder name as filename). This is unlikely to
be helpful, nor what you intend, and the single destination file
contents may be unrecoverable as separate files.

Merely to save a few characters in the command line, the
resulting command ambiguity may become a nasty problem
waiting to happen when you least expect or want it.
 
W

William Allen

You only need the trailing backslash. the *.* is superfluous.
....snip

Without the \*.* the syntax may fail in Windows 95/98/ME. With the
proper syntax, the command line is portable. Further, it's unwise to
save a few characters and leave the command syntax less clear.
 
F

foxidrive

in message
...snip

Without the \*.* the syntax may fail in Windows 95/98/ME.

Explain how. Why isn't it good enough to indicate to the file system that
it is a folder being copied into? Take into consideration the explanation
you gave before and snipped out.
 
A

Al Dunbar

William Allen said:
in message
...snip

Without the \*.* the syntax may fail in Windows 95/98/ME. With the
proper syntax, the command line is portable. Further, it's unwise to
save a few characters and leave the command syntax less clear.

I generally agree, however it is a rare batch file that I write these days
that will or can run on any 9X variant. One reason is that we have weaned
ourselves from 9x, and the other is that most of my scripts make use of
batch functionality that only became available in w2k. But to be sure, I
always use the .cmd extension.

Further, I find the "directoryname\" syntax to be a less ambiguous reference
to the fact that this is a directory. Having to include a file specification
like *.* makes it seem that a directory needs to have files before it really
is a directory.

/Al
 
M

Mark V

In said:
I generally agree, however it is a rare batch file that I write
these days that will or can run on any 9X variant. One reason is
that we have weaned ourselves from 9x, and the other is that
most of my scripts make use of batch functionality that only
became available in w2k. But to be sure, I always use the .cmd
extension.

Further, I find the "directoryname\" syntax to be a less
ambiguous reference to the fact that this is a directory. Having
to include a file specification like *.* makes it seem that a
directory needs to have files before it really is a directory.

Agree (with caveat over pre-NT OSs)

Just to note that in some cases making the target directory current
in advance can not only provide confirmation of it's existence, but
make COPY/XCOPY's target "." which in some cases may possibly be
the best approach. YMMV
 

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