Trying to copy from command line a file named "SCOOTE~1.txt" to a folder where there is a file called "Scooter - Cosmos.txt".
The problem is that copy will contract the name of "Scooter - Cosmos.txt" to "Scoote~1.txt" as well and will ask if I want to overwrite that file.
How can I literally copy the "SCOOTE~1.txt" without affecting other long-named files ? Suggestion of external command-line tools is accepted.
Recreation of Problem
Here the current directory has a file with a long-name of
Scooter - Cosmos.txt
and a short-name ofSCOOTE~1.TXT
(Note: the short-name is already in place at this stage). Also, the directorySFN
contains a file calledSCOOTE~1.TXT
– because this name "fits" in the 8.3 format, it does not have a separate short-name.If we now try to copy this file into the current directory, because the short-/only name of the file being copied matches the short-name of the file already present, it prompts about overwriting:
Single-Instance Fix
As eryksun suggested, you can use the
fsutil file setshortname
command to fix one-off clashes by changing the short-name of the file in the current directory:Here we can see that the short-name of
Scooter - Cosmos.txt
has been changed so that it no longer clashes withSCOOTE~1.TXT
; the copy proceeds with no warning and both files sit side-by-side in the current directory.Multiple-Instance Fix
If there are (or could be) several clashes with the files in the target directory, an alternative approach is to use the
fsutil 8dot3name strip
command to remove the 8.3-format short-names from all files at once:As can be seen, the file
Scooter - Cosmos.txt
no longer has a short-name, so there is no clash whenSCOOTE~1.TXT
is copied into the current directory:NOTE: The first stage of this command –
Scanning registry...
– may take some time as it is looking through the registry for references to the 8.3-format names that are about to be removed. Seefsutil 8dot3name strip /?
for more details of this command.Caution (Applies to both methods)
As the help from the
fsutil 8dot3name strip /?
command says:both these commands modify (or remove) the 8.3-format names of selected files. If you have any references to the files concerned (either in the registry, configuration files, or elsewhere in
.BAT
files etc.) then these references will no longer be valid. Use either solution with due caution.