Monday, November 16, 2015

windows - Cannot rename file with tilde


I have a ZIP file with only two files in it. They are named AUSWRTX1APE1.TXT(1) and AUSWRT~1.TXT(2).


My problem is, I cannot extract both files to the same (new & empty) folder. Windows complains that the file name already exists


You can reproduce the behavior: Create a new text file and name it AUSWRTX1APE1.TXT. Then, create a second text file at the same place and try to name it AUSWRT~1.TXT. Windows won't do this.


Are the tilde character and old Windows 8.3 short names my problem?


If someone has a more precise title, feel free to rename my question


Answer



Yes, the old DOS short names are the source of your problem. NTFS store a short name in addition to the long file name for compatibility reasons.


You can rename the AUSWRT~1.TXT to AUSWRT~2.TXT in the zip file before extracting, or you can change the beginning (AUSWRT) of AUSWRTX1APE1.TXT file name.


Another possibility is to disable the NTFS compatibility mode, but i don't recommend it.


EDIT for reply to comment:


As far as i know, the ~ is herited from retrocompatibility with FAT16 that was not able to use filenames longer than "xxxxxxxx.xxx" (12) characters. When a longer filename is created on FAT32, it shows in MSDOS as xxxxxx~1.xxx where ~1 is ~ + count of occurrences of the first 6 characters in filename


The rules for building the shortname are very complex. Please keep in mind, that they depend on the filename extension and that those rules are even different between old DOS-based Windows and NT-based ones.


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...