Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

W2K xcopy problem

Posted on 2001-08-29
5
Medium Priority
?
426 Views
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 ?
1
Comment
Question by:hagaiy
[X]
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
5 Comments
 
LVL 10

Accepted Solution

by:
tonnybrandt earned 800 total points
ID: 6436804
use
xcopy /R /Y file1 file2

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

Expert Comment

by:tonnybrandt
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]
                           [/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.

Hope this helps
Tonny
0
 
LVL 10

Expert Comment

by:tonnybrandt
ID: 6436823
Your questions:
1) Why does this happen ?
2)How can I avoid this question ?

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

Expert Comment

by:Longbow
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.

Alain
0
 

Expert Comment

by:thomasiqs
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.

EXAMPLE:

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.

Thomas
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

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…
Let's take a look into the basics of ransomware—how it spreads, how it can hurt us, and why a disaster recovery plan is important.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

609 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