Renaming Files While Copying May Cause Corruption

Last reviewed: May 8, 1997
Article ID: Q103040

The information in this article applies to:
  • Microsoft Windows NT operating system version 3.1
  • Microsoft Windows NT Advanced Server version 3.1

SYMPTOMS

With the Windows NT command prompt, if you use the COPY command to copy a file from one directory to another, you cannot rename the file simultaneously if you are using wildcards in the command line.

For example, if you have one file called TEST.EXE in a directory called ATEST, and you want to rename the file to BINARY.EXE while copying it, the file will be corrupted if you use the following command line:

   copy c:\atest\*.exe c:\binary.exe

The file will be partially copied, but will truncate at the first instance of CTRL-Z (EOF) in the file, causing a corrupted file.

WORKAROUND

To work around this problem, use a /b switch in front of the source file. This will correctly complete the copy and rename operation. For example:

   copy /b c:\atest\*.exe c:\binary.exe

Do not place the /b after the destination file. If you use a /b after the destination file as in the following example, the destination file will be corrupted:

   copy c:\atest\*.exe c:\binary.exe /b

Also, using the following command is the best way to copy and rename a file:

   copy c:\atest\test.exe c:\binary.exe

STATUS

Microsoft has confirmed this to be a problem in Windows NT version 3.1 and Windows NT Advanced Server version 3.1. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.


Additional query words: prodnt cmd
Keywords : kbbug3.10 kbtool ntfilesys ntutil
Version : 3.1
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: May 8, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.