Environment variables
 
Environment variables can be used in most places where directories are used, for example in the button bar, start menu, or command line.
New: It's now possible to use partial environment variables. The syntax is the same as in the command processor cmd.exe:
%variablename:~5,7%  skips 5 characters and uses the following 7. Negative numbers count from the end of the environment variable.
 
Total Commander supports 7 types of environment variables:
1. The regular Windows environment variables, e.g. %TEMP% or %USERNAME%. You can see the environment variables defined on your system by selecting "Commands" - "Open command prompt window" and enter the set command.
The way to change the environment variables depends on your Windows version:
- In Win9x/ME, the variables are set in the file autoexec.bat, like that: set temp=c:\temp
- In Windows NT/2000/XP, go to the Control Panel - System, open the page Advanced, and click the Environment Variables... button.
- In Windows Vista/7/8/8.1/10/11, go to the Control Panel - System, in the left column click Advanced system settings, then open the page Advanced, and click the Environment Variables... button.
- In Windows 10, it's: Start -> Settings -> System -> About -> Advanced system settings (on the right), and after that just like in the previous item.
 
2. Internal Total Commander variables:
%COMMANDER_DRIVE% Drive on which Total Commander is installed
%COMMANDER_EXE% Total Commander file name including path
%COMMANDER_INI% Total Commander settings file including path
%COMMANDER_INI_PATH% The directory of the Total Commander settings file (without trailing backslash)
%COMMANDER_INSTANCE% Instance number, as shown in title bar (first instance = 1)
%COMMANDER_PATH% The Total Commander directory (without trailing backslash)
%COMMANDER_SESSIONNAME% Contains the text admin when Total Commander was started with administrator rights, user otherwise
%COMMANDER_OPEN% Origin of launch, set when launching external program. One of:
bar Button bar button
changeini Menu Configuration - Change ini files directly
cmd Menu Commands - Open command prompt window
cmdline Command line
contextmenu Right click context menu
delete Delete from archive (launching external packer)
edit F4 in main program
editlistfile Edit list file in background transfer manager
editname cm_Edit called with parameter /N="name"
editnew Shift+F4 in main program, or cm_Edit /C
find F4 in Commands - Search
hotkey User-defined hotkey
hotlist Directory hotlist
lister F4 in Lister
menu Menu "Start"
mrtlist Edit names in the Multi-rename tool
new Context menu, submenu "New"
open Enter or double click
opencontextmenu Enter or double click opened context menu from internal association
pack Pack with external packer
sync F4, Shift+F4 or context menu in the Sync tool
unpack Unpack with external packer
view View with external viewer (default Alt+F3)
viewmode User-defined view mode with em_command in "auto-run commands"
 
3. Special pseudo environment variable %$DATE%:
%$DATE% Inserts the 24 hour date and time in the form YYYYMMDDhhmmss
%$DATE:placeholders% Inserts the date in the form specified by placeholders. Same as in multi-rename tool:
Y Paste year in 4 digit form
y Paste year in 2 digit form
M Paste month, always 2 digit
D Paste day, always 2 digit
h Paste hours, always in 24 hour 2 digit format (0-23)
H Paste hours, always in 12 hour 2 digit format (1-12) 
i am/pm indicator in English
i1 same but 1 character a/p only
m Paste minutes, always in 2 digit format
s Paste seconds, always in 2 digit format
any non-alpha character like a dot or dash will be added directly  
%$DATE+offset% / %$DATE-offset% Inserts the 24 hour date and time in the form YYYYMMDDhhmmss with added/subtracted offset:
Value followed by unit: s=seconds, m=minutes, h=hours, D=days, M=months, Y=years
  Examples: %$DATE+1Y% or %$DATE-30m%
%$DATE:placeholders+offset% (or -) Inserts the date in the form specified by placeholders with added/subtracted offset (same as above)
 
4. Special pseudo environment variable %$CLIPBOARD%, %$CLIPNAME% and %$CLIPNAME_NE%:
%$CLIPBOARD% Inserts up to 8191 unmodified characters from the clipboard
%$CLIPBOARD0% Like %$CLIPBOARD%, but line breaks are replaced by spaces, cut at last line break if buffer too small
%$CLIPBOARD1%, %$CLIPBOARD2% Inserts line 1, line 2 etc. from the clipboard, otherwise unchanged
%$CLIPNAME% Inserts up to 8191 characters from the clipboard, replaces the characters *?|<> that are forbidden in file names with underscores_
%$CLIPNAME0% Like %$CLIPNAME%, but line breaks are replaced by spaces, cut at last line break if buffer too small
%$CLIPNAME1%, %$CLIPNAME2% Inserts line 1, line 2 etc. from the clipboard, replaces the characters *?|<> that are forbidden in file names with underscores_, and removes leading and trailing spaces and characters with code<32.
%$CLIPNAME_NE1%, %$CLIPNAME_NE2%
Like %$CLIPNAME1%, %$CLIPNAME2%, but skips empty lines
%$CLIPNAMEQ1%, %$CLIPNAMEQ2%, %$CLIPNAME_NEQ1%, %$CLIPNAME_NEQ2%
Like %$CLIPNAME1%, %$CLIPNAME2%, %$CLIPNAME_NE1%, %$CLIPNAME_NE2%, but surrounds name with double quotes if it contains at least one space, e.g. name 1.txt -> "name 1.txt". Use a lowercase 'q' to always surround name with double quotes.
 
5. Pseudo environment variables from parameters of the function ShGetSpecialFolderLocation. Syntax: %$NAME%
The following variables are supported (at least the first character must be uppercase):
APPDATA,
DESKTOP,
PERSONAL,
PROGRAMS,
STARTMENU,
STARTUP,
FONTS,
MYPICTURES,
LOCAL_APPDATA,
COMMON_APPDATA,
COMMON_DESKTOPDIRECTORY,
COMMON_DOCUMENTS,
COMMON_PROGRAMS,
COMMON_STARTMENU,
COMMON_STARTUP,
COMMON_PICTURES,
MYVIDEO,
MYMUSIC
 
6. Pseudo environment variables from parameters of the function SHGetKnownFolderPath. Syntax: %$Name%
The following variables are supported:
AccountPictures,
AdminTools,
CameraRoll,
CDBurning,
CommonAdminTools,
CommonOEMLinks,
CommonPrograms,
CommonStartMenu,
CommonStartup,
CommonTemplates,
Contacts,
Cookies,
DeviceMetadataStore,
Documents,
Downloads,
Favorites,
GameTasks,
History,
ImplicitAppShortcuts,
InternetCache,
Libraries,
Links,
LocalAppData,
LocalAppDataLow,
LocalizedResourcesDir,
Music,
NetHood,
OriginalImages,
PhotoAlbums,
Pictures,
Playlists,
PrintHood,
Profile,
ProgramData,
ProgramFiles,
ProgramFilesX64,
ProgramFilesX86,
ProgramFilesCommon,
ProgramFilesCommonX64,
ProgramFilesCommonX86,
Public,
PublicDesktop,
PublicDocuments,
PublicDownloads,
PublicGameTasks,
PublicLibraries,
PublicMusic,
PublicPictures,
PublicRingtones,
PublicUserTiles,
PublicVideos,
QuickLaunch,
Recent,
ResourceDir,
Ringtones,
RoamingAppData,
RoamedTileImages,
RoamingTiles,
SampleMusic,
SamplePictures,
SamplePlaylists,
SampleVideos,
SavedGames,
SavedPictures,
SavedSearches,
Screenshots,
SearchHistory,
SearchTemplates,
SendTo,
SidebarDefaultParts,
SidebarParts,
SkyDrive,
SkyDriveCameraRoll,
SkyDriveDocuments,
SkyDrivePictures,
System,
SystemX86,
Templates,
UserPinned,
UserProfiles,
UserProgramFiles,
UserProgramFilesCommon,
Videos,
Windows
 
7. Passing a GUID directly to the function SHGetKnownFolderPath. Syntax: %${GUID}%
Example:
%${374DE290-123F-4565-9164-39C4925E467B}%  -> download folder, same as %$Downloads%