Because of the short file name feature of windows NT, the OS automatically strips tilde characters from the file name, leaving just a space.
What this means is that
when windows writes the file to the destination.
When you then go and copy an actual file called 'ABC 123.txt' it complains because there's a file with that name already there.
In order for it to be recognized as a short file name, the tilde MUST be a sequential number of characters from the end of the name.
so if you have 2 file names, and a likely file name collision, your 2 files MUST be called
anything else that breaks the sequence, windows will interpret as a normal long file name and attempt to remove the tilde character.
It was for this reason, when long file names where first introduced in Windows 95, that so many pieces of software got broken, or corrupted files they where writing.
It was simply down to applications using what they got back from a directory call, tildes and all, and not respecting that there was a sequence there, which NTFS was keeping track of.
It appears I didn't quite make the sequential aspect of things too clear, So i'll try and expand on it a little bit.
When windows names long files with short file names, there are 2 forces at play, first is that short file names are limited to 8 characters for the file name and 3 for the extension, secondly a lot of the characters allowed in long file names are not allowed in short.
Putting point 2 aside, and concentrating on point 1, this often means that with less than 10 similarly named files (It gets a bit more complicated with 10 or beyond) you typically only get 6 characters to name your file, and the remaining 2 are required for the sequential numbering.
Windows will start at ~1 and count up to ~9, typically concatenating that onto the first 6 legal characters of the file name, so if you saved 3 files, that resulted in 3 names you'd get:
The following long file names, would easily generate these, although so would others (But I'm trying to keep the example simple):
Now, if you where then, too manually save a file called
Windows would NOT remove the tilde, why?
Simply because it recognizes that 4 comes after 3 and so it treats it like there are 4 shortened file names and puts it sequentially as expected.
If you then followed that with another file write to EG:
Windows will create a short file called:
Again because it respects the file sequence.
However, if you go back a step to where you created ~4 manually and instead created ~5, ~6 or anything out of sequence, windows should remove the tilde, because it now sees that the file your saving is not in sequence with the rest, and so it interperates that as NOT being a short form name, but rather a long form name, for which it then has to automatically generate a corresponding short file name.
There's a lot of complicated rules as to when windows (or more specifically NTFS) decides when and what to change, and frequently, just when you think you've got it, it goes and does something very unexpected.
Back in mid 90's it used to cause myself (and lot's of others like me) major headaches, esp accross networking systems such as netbios and novell netware, I'm glad it's all behind now and we can just use long names 99% of the time :-)