Questions

Cmd prompt xcopy

+
0 Votes
Locked

Cmd prompt xcopy

peter_mallory
I'd like to know how to suppresses prompting to confirm you want to overwrite an existing destination file, but set this to "No".
At present: xcopy C:\source/S/C/Y D:\destination
however this defaults to overwriting the already copied files. Is there a was in cmd prompt to suppress the prompt and NOT overwrtie existing files?
  • +
    0 Votes
    p.j.hutchison

    TRy the Robocopy tool which comes with Windows 2003 Resource Kit instead which might do it better than XCopy. The Kit can be installed on any version of Windows XP.

    +
    0 Votes
    peter_mallory

    Still cannot restart copy process and supress the overwrite dialogue and set as no as opposed to default of yes

    +
    0 Votes
    robert_j_dixon

    Peter, probably way too late for you, but the order of cmdline parameters might be the problem.

    I'm using:
    xcopy source dest /Y /S /M /C
    under WinXP SP2.
    Most of the DOS/CMD commands are very fussy (aka dumb) about parsing the cmdline, unlike *nix commands.

    Robert D.

    +
    0 Votes
    ComputerCookie

    Do you want to append existing files or create a new destination file?

    +
    0 Votes
    afgborel

    FROM MS SUP. SITE

    "/Y Suppresses prompting to confirm you want to overwrite an
    existing destination file.
    /-Y Causes prompting to confirm you want to overwrite an
    existing destination file."


    Xcopy
    Copies files and directory trees.

    XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W]
    [/C] [/Q] [/F] [/L] [/H] [/R] [/T]
    [/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z]
    [/EXCLUDE:file1[+file2][+file3]...]

    source Specifies the file(s) to copy.
    destination Specifies the location and/or name of new files.
    /A Copies only files with the archive attribute set,
    doesn't change the attribute.
    /M Copies only files with the archive attribute set,
    turns off the archive attribute.
    /D:m-d-y Copies files changed on or after the specified date.
    If no date is given, copies only those files whose
    source time is newer than the destination time.
    /EXCLUDE:file1[+file2][+file3]...
    Specifies a list of files containing strings. When any of the
    strings match any part of the absolute path of the file to be
    copied, that file will be excluded from being copied. For
    example, specifying a string like \obj\ or .obj will exclude
    all files underneath the directory obj or all files with the
    .obj extension respectively.
    /P Prompts you before creating each destination file.
    /S Copies directories and subdirectories except empty ones.
    /E Copies directories and subdirectories, including empty ones.
    Same as /S /E. May be used to modify /T.
    /V Verifies each new file.
    /W Prompts you to press a key before copying.
    /C Continues copying even if errors occur.
    /I If destination does not exist and copying more than one file,
    assumes that destination must be a directory.
    /Q Does not display file names while copying.
    /F Displays full source and destination file names while copying.
    /L Displays files that would be copied.
    /H Copies hidden and system files also.
    /R Overwrites read-only files.
    /T Creates directory structure, but does not copy files. Does not
    include empty directories or subdirectories. /T /E includes
    empty directories and subdirectories.
    /U Copies only files that already exist in destination.
    /K Copies attributes. Normal Xcopy will reset read-only attributes.
    /N Copies using the generated short names.
    /O Copies file ownership and ACL information.
    /X Copies file audit settings (implies /O).
    /Y Suppresses prompting to confirm you want to overwrite an
    existing destination file.
    /-Y Causes prompting to confirm you want to overwrite an
    existing destination file.
    /Z Copies networked files in restartable mode.

    The switch /Y may be preset in the COPYCMD environment variable.
    This may be overridden with /-Y on the command line.

    +
    0 Votes
    LarryD4

    Why not just set the files you don't want overwritten to read only?

    Then the only way XCopy would overwrite them is if you use the switch that tells it to overwrite read only files.

    +
    0 Votes

    Or

    LarryD4

    Write a VB script that will only copy files that are not present in the destination folder.

    +
    0 Votes
    joseph

    if not exist c:\targetfile.txt copy d:\sourcefile.txt c:\

  • +
    0 Votes
    p.j.hutchison

    TRy the Robocopy tool which comes with Windows 2003 Resource Kit instead which might do it better than XCopy. The Kit can be installed on any version of Windows XP.

    +
    0 Votes
    peter_mallory

    Still cannot restart copy process and supress the overwrite dialogue and set as no as opposed to default of yes

    +
    0 Votes
    robert_j_dixon

    Peter, probably way too late for you, but the order of cmdline parameters might be the problem.

    I'm using:
    xcopy source dest /Y /S /M /C
    under WinXP SP2.
    Most of the DOS/CMD commands are very fussy (aka dumb) about parsing the cmdline, unlike *nix commands.

    Robert D.

    +
    0 Votes
    ComputerCookie

    Do you want to append existing files or create a new destination file?

    +
    0 Votes
    afgborel

    FROM MS SUP. SITE

    "/Y Suppresses prompting to confirm you want to overwrite an
    existing destination file.
    /-Y Causes prompting to confirm you want to overwrite an
    existing destination file."


    Xcopy
    Copies files and directory trees.

    XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W]
    [/C] [/Q] [/F] [/L] [/H] [/R] [/T]
    [/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z]
    [/EXCLUDE:file1[+file2][+file3]...]

    source Specifies the file(s) to copy.
    destination Specifies the location and/or name of new files.
    /A Copies only files with the archive attribute set,
    doesn't change the attribute.
    /M Copies only files with the archive attribute set,
    turns off the archive attribute.
    /D:m-d-y Copies files changed on or after the specified date.
    If no date is given, copies only those files whose
    source time is newer than the destination time.
    /EXCLUDE:file1[+file2][+file3]...
    Specifies a list of files containing strings. When any of the
    strings match any part of the absolute path of the file to be
    copied, that file will be excluded from being copied. For
    example, specifying a string like \obj\ or .obj will exclude
    all files underneath the directory obj or all files with the
    .obj extension respectively.
    /P Prompts you before creating each destination file.
    /S Copies directories and subdirectories except empty ones.
    /E Copies directories and subdirectories, including empty ones.
    Same as /S /E. May be used to modify /T.
    /V Verifies each new file.
    /W Prompts you to press a key before copying.
    /C Continues copying even if errors occur.
    /I If destination does not exist and copying more than one file,
    assumes that destination must be a directory.
    /Q Does not display file names while copying.
    /F Displays full source and destination file names while copying.
    /L Displays files that would be copied.
    /H Copies hidden and system files also.
    /R Overwrites read-only files.
    /T Creates directory structure, but does not copy files. Does not
    include empty directories or subdirectories. /T /E includes
    empty directories and subdirectories.
    /U Copies only files that already exist in destination.
    /K Copies attributes. Normal Xcopy will reset read-only attributes.
    /N Copies using the generated short names.
    /O Copies file ownership and ACL information.
    /X Copies file audit settings (implies /O).
    /Y Suppresses prompting to confirm you want to overwrite an
    existing destination file.
    /-Y Causes prompting to confirm you want to overwrite an
    existing destination file.
    /Z Copies networked files in restartable mode.

    The switch /Y may be preset in the COPYCMD environment variable.
    This may be overridden with /-Y on the command line.

    +
    0 Votes
    LarryD4

    Why not just set the files you don't want overwritten to read only?

    Then the only way XCopy would overwrite them is if you use the switch that tells it to overwrite read only files.

    +
    0 Votes

    Or

    LarryD4

    Write a VB script that will only copy files that are not present in the destination folder.

    +
    0 Votes
    joseph

    if not exist c:\targetfile.txt copy d:\sourcefile.txt c:\