Sync tool cant sync when %foo% in a dir name
Moderators: Hacker, petermad, Stefan2, white
Sync tool cant sync when %foo% in a dir name
I've tried to sync a folder with a folder named %ProgramFiles%, and Sync tool can't compare, it says that path is invalid. I suppose it tries to expand envvar and fails, but it shouldn't in this case because %foo% sequences are valid in directory names.
Re: Sync tool cant sync when %foo% in a dir name
Well, Windows does the same if you use cd c:\%Programfiles% in a command prompt - it reports back:
The filename, directory name, or volume label syntax is incorrect.
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
-
- New Member
- Posts: 1
- Joined: 2025-01-28, 23:03 UTC
Re: Sync tool cant sync when %foo% in a dir name
It's probably unwise to name a folder after an environment variable in Windows but if you insist, you'll have to escape the %'s using a ^ (caret).
I can't speak to the Sync tool specifically but lets say you've created a folder called "c:\%ProgramFiles%". In order to "cd" into it using a command prompt, you're going to have to use the following:
cd c:\^%ProgramFiles^%
You can obtain a list of other environment variables in Windows that'll need escaping by using a command prompt and issuing the folloing command:
set
I can't speak to the Sync tool specifically but lets say you've created a folder called "c:\%ProgramFiles%". In order to "cd" into it using a command prompt, you're going to have to use the following:
cd c:\^%ProgramFiles^%
You can obtain a list of other environment variables in Windows that'll need escaping by using a command prompt and issuing the folloing command:
set
- ghisler(Author)
- Site Admin
- Posts: 50383
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Re: Sync tool cant sync when %foo% in a dir name
This behaviour is intentional and will not be changed. It is very useful to be able to use environment variables in places like the multi-rename tool or on a button with the "cd" command. Total Commander will not touch the path if there is no environment variable with that name. It will also only change it when the path appears in the left or right directory field. You could start sync one level higher and select the directory you want to sync.
One idea would be to not replace environment variables if the resulting path would be invalid, e.g. when %ProgramFiles% is replaced with a path starting with a drive letter, and is present in the middle of a path. Another idea would be to first check whether a path exists before replacing environment variables.
One idea would be to not replace environment variables if the resulting path would be invalid, e.g. when %ProgramFiles% is replaced with a path starting with a drive letter, and is present in the middle of a path. Another idea would be to first check whether a path exists before replacing environment variables.
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
- ghisler(Author)
- Site Admin
- Posts: 50383
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Re: Sync tool cant sync when %foo% in a dir name
In RC4, I have now implemented the partial solution that when an environment variable contains a path, it will not be replaced in the middle of a directory. So far this is limited to the synchronize dirs tool only.
This doesn't solve the problem for variables containing other things than paths, though.05.02.25 Fixed: Synchronize dirs: Do not replace environment variables like %ProgramFiles% which resolve to a directory in the middle of a path (32/64)
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
- ghisler(Author)
- Site Admin
- Posts: 50383
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Re: Sync tool cant sync when %foo% in a dir name
Since this is a partial fix only, and I don't want to break anything, I'm moving this to will not be changed.
Moderator message from: ghisler(Author) » 2025-02-10, 09:27 UTC
Moved to will not be changed
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com