• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 611
  • Last Modified:

XCOPY parameter

I'm using the following batch script to copy a file off the server to my C drive.

net use z: \\nnsql\application /user:server\username password
set tdate=%DATE:~4,2%%DATE:~7,2%
XCOPY  Z:\testcopy_cmd.txt C:\Nnsqlbck\testcopy_cmd_%tdate%.txt /c /i
When I execute the above script file it prompts me for following. see below.
C:\My Documents>XCOPY  Z:\testcopy_cmd.txt C:\Nnsqlbck\testcopy_cmd_1123.txt /c /i
Does C:\Nnsqlbck\testcopy_cmd_1123.txt specify a file name
or directory name on the target
(F = file, D = directory)?

Is there a  parameter (i.e. /c../i...etc) that I can use to eliminate the above prompt so it can be copied automatically.  When I type the letter F, it copies the file.
3 Solutions
  per the MS help file,
/i : If Source is a directory or contains wildcards and Destination does not exist, xcopy assumes destination specifies a directory name and creates a new directory. Then, xcopy copies all specified files into the new directory. By default, xcopy prompts you to specify whether Destination is a file or a directory.

buy why not just use copy?  The normal copy command should work for you.

NBillyAuthor Commented:
I'll try your suggestion.  Thanks.
Julian HansenCommented:
Another way is to do pipe F to the command

echo F | xcopy Z:\testcopy_cmd.txt C:\Nnsqlbck\testcopy_cmd_%tdate%.txt /c /i /y

Depending on whether or not you want to overwrite an existing file you might want to add the /y paramter.

Try this:

echo f | XCOPY  Z:\testcopy_cmd.txt C:\Nnsqlbck\testcopy_cmd_%tdate%.txt /c

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now