XCOPY parameter

Posted on 2004-11-23
Last Modified: 2008-01-09
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.
Question by:NBilly
    LVL 7

    Accepted Solution

      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.


    Author Comment

    I'll try your suggestion.  Thanks.
    LVL 49

    Assisted Solution

    by:Julian Hansen
    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.

    LVL 19

    Assisted Solution

    Try this:

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

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Suggested Solutions

    This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
    Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now