• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 435
  • Last Modified:

W2K xcopy problem

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
hagaiy
Asked:
hagaiy
  • 3
1 Solution
 
tonnybrandtCommented:
use
xcopy /R /Y file1 file2

/Y answers yes for you.
/R overwrites read-only files
0
 
tonnybrandtCommented:
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
 
tonnybrandtCommented:
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
 
LongbowCommented:
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
 
thomasiqsCommented:
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now