W2K xcopy problem

Posted on 2001-08-29
1 Endorsement
Last Modified: 2010-08-05
Hi , fellows.
I work with W2K. I want to copy one file into another
existing file using xcopy.
xcopy /R file1 file2
And I get this:
Overwrite file2 (Yes/No/All)?
1) Why does this happen ?
2)How can I avoid this question ?
Question by:hagaiy
  • 3
LVL 10

Accepted Solution

tonnybrandt earned 200 total points
Comment Utility
xcopy /R /Y file1 file2

/Y answers yes for you.
/R overwrites read-only files
LVL 10

Expert Comment

Comment Utility
Here is all the parameters:

E:\>xcopy /?
Copies files and directory trees.

XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W]
                           [/C] [/I] [/Q] [/F] [/L] [/H] [/R] [/T] [/U]
                           [/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z]

  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.
               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.

Hope this helps
LVL 10

Expert Comment

Comment Utility
Your questions:
1) Why does this happen ?
2)How can I avoid this question ?

1) Because xcopy default will want you to confirm that overwriting a file is ok.
2) By using the /Y switch
LVL 10

Expert Comment

Comment Utility
Hi Hagaly,

The simplest way is to use the "Type" DOS command.
Type file1>>file2 with the complete path of each file if needed.
This command will appent the content of the 1st file at the end of the 2nd file.
Only one > will overwrite the file
>> will append to the 2nd file.


Expert Comment

Comment Utility
Instead of using XCOPY, use plain old copy in the following fashion:

copy [destination file]+[file1]+[file2]+[file10.....

If they are ASCII text files, append "/a" at the end of the line above. A "/b" if appending binary files.


Given: 3 ASCII text files called Mainfile.txt, Test1.txt, Test2.txt

To "concatenated" the text from test1.txt and test2.txt into mainfile.txt, the following would entered at the command prompt:

copy mainfile.txt+test1.txt+test2.txt /a

While the "Type" command suggested by Alain is good for appending two text based files, it would not work for concatenating multiple files and would not work for combining binary files at all.

In the old DOS days, we used to split binary files that could not fit on floppy based media (no ZIP drives back then), then carry them to the new system and use this concatenation feature of the copy command to recombine them. This feature was never added to XCOPY that I am aware of.  Too bad.  XCOPY makes better use of the large amounts of memory on today's PCs. Still, the COPY command is still an intrinsic OS command, so it is always there for use if the XCOPY.EXE program is not handy.


Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
In this article, I will show you HOW TO: Create your first Windows Virtual Machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, the Windows OS we will install is Windows Server 2016.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 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

9 Experts available now in Live!

Get 1:1 Help Now