Solved

W2K xcopy problem

Posted on 2001-08-29
5
406 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
  • 3
5 Comments
 
LVL 10

Accepted Solution

by:
tonnybrandt earned 200 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

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…
This article describes my battle tested process for setting up delegation. I use this process anywhere that I need to setup delegation. In the article I will show how it applies to Active Directory
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

808 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