Renaming Files While Copying May Cause Corruption (103040)



The information in this article applies to:

  • Microsoft Windows NT Server 3.1
  • Microsoft Windows NT Workstation 3.1
  • Microsoft Windows NT Advanced Server 3.1

This article was previously published under Q103040

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.

Modification Type:MajorLast Reviewed:4/8/2004
Keywords:KB103040