Ramses Asmush
Ramses Asmush

Reputation: 164

Windows program files path names?

Maybe this can be a silly question but I don't figure out how to search in google why in some code I read, it is used to write this way: \\progra~1

What does ~ and 1 mean? I tried executing in Windows Run the same path but changing numbers and these are the results:

C:\progra~1 -> Opens Program Files
C:\progra~2 -> Opens Program Files(x86)
C:\progra~3 -> Opens ProgramData
C:\progra~4 -> Opens ProgramDevices, a folder I created in C:\

Why? Is this like a Match or something in the Folder names list?

For example a regex like "progra" and then to show the ~1 (First) match in some X order or ~2 (Second) ... etc?

Upvotes: 1

Views: 256

Answers (2)

Order23
Order23

Reputation: 71

It's a compatability mode with the old (really old) windows 8.3 naming convention. The ~n represents the instance of the name that has the same root characters.

In your example: Program Files and Program Files(x86) have the same root characters Progra. Hence one gets progra~1, the next progra~2 etc.

8.3 compatability can be turned off for a disk partition.

Upvotes: 3

Michal_Szulc
Michal_Szulc

Reputation: 4177

Exactly, it's a pattern counter. Check out also this answer: What does %~d0 mean in a Windows batch file?

You can find more examples of different variables with modifiers here:

https://technet.microsoft.com/en-us/library/bb490909.aspx (ctrl-f for "Variable substitution")

Upvotes: 1

Related Questions