Steps to reproduce:
01. Create a directory inside Total Commander (F7) with the name %NUMBER_OF_PROCESSORS% (or %OS%, etc).
02. Type the following to the command line of Total Commander: cd %NUMBER_OF_PROCESSORS%
03. No effect - Total Commander automatically replaces the %NUMBER_OF_PROCESSORS% to 2 (in my case), and since the directory called "2" doesn't exists at all, nothing happens.
Tested under Windows 7 SP1, with TC versions: 7.56a & 8.0b10.
Edit: also theres no effect if you manually edit the path (by double clicking the current path, and copy-pasting "c:\%NUMBER_OF_PROCESSORS%") - TC fails to enter the directory (the only way it works is the breadcrumb bar, or by manually pressing an enter on it).
Problem with environment variable-named directories
Moderators: Hacker, petermad, Stefan2, white
Who in their right mind will use the name of a system environment variable as a folder name ?
(or any environment variable for that matter).
IMHO TC just does, what you tell it to do: resolves the env. var. %NUMBER_OF_PROCESSORS% and tries to go to a directory with he resolved value.

IMHO TC just does, what you tell it to do: resolves the env. var. %NUMBER_OF_PROCESSORS% and tries to go to a directory with he resolved value.
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Ahem... me?
Anyway i see your point, as i found this bug by an accident while developing an external TC utility - however i think this isn't the way Total Commander should work in this case (as i haven't told TC to resolve the environment variable, it happened automatically)...
I mean if you create two folders:
c:\2 (if you actually have 2 cores)
c:\%NUMBER_OF_PROCESSORS%
... and type cd %NUMBER_OF_PROCESSORS% to the command line of TC, it should check if the directory after "cd" command exists or not in the current path:
- a) %NUMBER_OF_PROCESSORS% exists - enter to the directory (do not resolve it)
- b) %NUMBER_OF_PROCESSORS% doesn't exists - lets resolve the environment variable (if possible), and check if a dir with the name of the resolved value exists or not (enter to the dir in case it exists)
- c) none of them exists - do nothing
Instead of the above, if you type the command and press enter (and a directory called "1" or "2" and "%NUMBER_OF_PROCESSORS%" exists in the same place), Total Commander enters into "1" or "2" - and thats not what the user told to do.
So i have one question: put the case that i really need this %NUMBER_OF_PROCESSORS% folder - how can i enter into it using Total Commander's command line?

Anyway i see your point, as i found this bug by an accident while developing an external TC utility - however i think this isn't the way Total Commander should work in this case (as i haven't told TC to resolve the environment variable, it happened automatically)...
I mean if you create two folders:
c:\2 (if you actually have 2 cores)
c:\%NUMBER_OF_PROCESSORS%
... and type cd %NUMBER_OF_PROCESSORS% to the command line of TC, it should check if the directory after "cd" command exists or not in the current path:
- a) %NUMBER_OF_PROCESSORS% exists - enter to the directory (do not resolve it)
- b) %NUMBER_OF_PROCESSORS% doesn't exists - lets resolve the environment variable (if possible), and check if a dir with the name of the resolved value exists or not (enter to the dir in case it exists)
- c) none of them exists - do nothing
Instead of the above, if you type the command and press enter (and a directory called "1" or "2" and "%NUMBER_OF_PROCESSORS%" exists in the same place), Total Commander enters into "1" or "2" - and thats not what the user told to do.
So i have one question: put the case that i really need this %NUMBER_OF_PROCESSORS% folder - how can i enter into it using Total Commander's command line?
Configuration->Options-> Misc.So i have one question: put the case that i really need this %NUMBER_OF_PROCESSORS% folder - how can i enter into it using Total Commander's command line?
(x) alias: cdd
[magnifier button] -> [New] enter em_cd
under commands enter cd
[ok] [ok] [green checkmark button]
command line wrote:cdd %%NUMBER_OF_PROCESSORS%%

Holger
- Balderstrom
- Power Member
- Posts: 2148
- Joined: 2005-10-11, 10:10 UTC
None of the normal cmd.exe methods work, directly from the command-line.
I recall this was discussed in at least one thread that MVV and I partook in.
This is how a real command prompt handles it:
1) CD %"USERNAME"%
---> will change dir to %USERNAME% - not resolved as a variable.
2) CD ^%USERNAME^%
---> again, will not resolve the Environment variable.
TC treats both of those as "valid" folder names, and doesn't find them. Instead of ignoring the quote and or caret, and treating the first one as a valid way to block environment variable expansion.
I recall this was discussed in at least one thread that MVV and I partook in.
This is how a real command prompt handles it:
1) CD %"USERNAME"%
---> will change dir to %USERNAME% - not resolved as a variable.
2) CD ^%USERNAME^%
---> again, will not resolve the Environment variable.
TC treats both of those as "valid" folder names, and doesn't find them. Instead of ignoring the quote and or caret, and treating the first one as a valid way to block environment variable expansion.
*BLINK* TC9 Added WM_COPYDATA and WM_USER queries for scripting.
- ghisler(Author)
- Site Admin
- Posts: 50386
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Indeed in the command line, environment variables are always resolved. I don't currently have any plans to change that. You can enter the folder by double clickibg or with the ENTER key, though.
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
@ghisler(Author):
But not programatically (for example by using WM_COPYDATA message) from an external tool.
Anyway i see, so the point is theres actually no clean way of doing that, and that won't change within reasonable time - thanks to everyone for the replies.
@HolgerK:
Nice workaround, thank you - this way it works like a charm. The only fly in the ointment is that it needs an extra usercmd option, but thats not a big deal in my case...
But not programatically (for example by using WM_COPYDATA message) from an external tool.
Anyway i see, so the point is theres actually no clean way of doing that, and that won't change within reasonable time - thanks to everyone for the replies.
@HolgerK:
Nice workaround, thank you - this way it works like a charm. The only fly in the ointment is that it needs an extra usercmd option, but thats not a big deal in my case...