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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
LVL 10

Accepted Solution

tonnybrandt earned 200 total points
ID: 6436804
xcopy /R /Y file1 file2

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

Expert Comment

ID: 6436806
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

ID: 6436823
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

ID: 6436888
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

ID: 7112754
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

740 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