tags:

views:

80

answers:

3

I saw it here:

cimg_snprintf(st_path,sizeof(st_path),"D:\\IMAGEM~1.%d\\VISUA~1\\BIN\\convert.exe",k);
+4  A: 

It's the short (8.3) name of the folder.

In the "old days" DOS file names used to be limited to 12 characters - 8 for the name + dot + 3 for the extension. When Windows was extended to handle long names this old format still existed and the long name was truncated to fit behind the scenes. It's this that you're seeing.

If the file name needs to be truncated then it gets truncated to 6 characters and "~1" appended. If there's already a file/folder of that name it increments the number until it finds one that doesn't exist - hence "~2" or "~3".

Sometimes it will be used to keep the overall length of a path down to as short as possible, or if the code needs to ensure that there aren't any spaces in the path.

ChrisF
What do you mean by 8.3?
8.3 means 8 characters for the name of a file, 3 for the extension.
PeterK
@user198729 - I've updated the answer with a bit of explanation
ChrisF
How is ~1 ,~2 determined?
And for anyone too young to know what DOS was: it's what we called Windows before it had windows.
Mike Seymour
It's usually just the next available name in the 8.3 namespace. However I've seen some installers generate much larger numbers (50/60) without any obvious need - I think that was a Visual Studio or Platform SDK. I wouldn't try and guess these; you can check manually using dir /X and there's almost certainly a Windows API if you need this programatically.
Rup
@user198729: Sequencially within the folder. Copy a file to a new directory, and it's short name could be different in the new location.
James Curran
Is it sorted alphabetically?
@user198729 - "dir /?" will give you the help. "dir /o:n" will sort by name alphabetically.
ChrisF
@user198729: Many year ago, I wrote a newsgroup message about that: http://groups.google.com/group/alt.folklore.computers/msg/d9a0a1f7c7cf2f51
James Curran
I mean, how to determine which one is `~1`,while the other is `~2`? Can you elaborate about the sequence?
@user198729 - it all depends on what order the files are created in. "dir /x" (as has been mentioned before) will give you the short and long names so you can see which is which.
ChrisF
@user198729: There's no way to predict in advance. But why are you using the shortname anyway? Just use the long name instead:
James Curran
@James - the OP isn't using it himself, but has seen it in some code he's using/modifying.
ChrisF
@ChrisF: Then why would he need to predict the shortname? If he's going to change the code he's found, he should change it to use the long name.
James Curran
@James - I was assuming that he just wanted to understand more about how the it works.
ChrisF
+7  A: 

Its called DOS 8.3 format of naming files

Dave18
+5  A: 

If it's convert.exe, it's probably ImageMagick.

As above, this is the 8.3 compatibility version of the filename (which you can see with dir /X) and is often used to construct a pathname without spaces where they might cause problems.

Rup