Feature Request: Fully expand indirect environmental variables in Folder Pairs

Get help for specific problems
User avatar
Posts: 8
Joined: 18 Jan 2018

samkatakouzinos

Dear FreeFileSync Development Team,

I have been using environmental variables for Folder Pair paths in FreeFileSync, and it has been an incredibly helpful feature. It allows me to reuse .ffs_gui files across multiple computers, simplifying my synchronization tasks.

Current Setup
On my computers, I define the following system environmental variables:
fs = D:\fs ; primary file location on a large, slower HDD; main FFS network sync target
fs2 = C:\fs ; secondary file location on a smaller, faster SSD; main FFS local sync target
mch = 005 ; a unique identifier for each computer

An example Folder Pair:
%fs%\0\m\%mch%\0\w\s\scripts | %fs2%\0\m\%mch%\0\w\s\scripts
Expected Actual Result:
D:\fs\0\m\005\0\w\s\scripts | C:\fs\0\m\005\0\w\s\scripts

My Challenge
Not all of my computers have a D: drive; some use E: or other drive letters. To address this, I’ve implemented indirect environmental variables per computer:
fsC = C:\fs ; direct environmental variable
fsE = E:\fs ; direct environmental variable
mch = 005 ; direct environmental variable
fs = %fsE% ; indirect environmental variable
fs2 = %fsC% ; indirect environmental variable

This setup allows my scripts to remain functional across all systems by referencing %fs% and %fs2% consistently.

My Issue
However, FreeFileSync does not fully expand indirect environmental variables in Folder Pairs. Instead of expanding the variables %fs% and %fs2% to their final paths (E:\fs, C:\fs, etc.), it stops at the intermediate values (%fsE%, %fsC%). For example:

Folder Pair:
%fs%\0\m\%mch%\0\w\s\scripts | %fs2%\0\m\%mch%\0\w\s\scripts
Expected Result:
D:\fs\0\m\005\0\w\s\scripts | C:\fs\0\m\005\0\w\s\scripts
Actual Incorrect Result:
C:\Program Files\FreeFileSync\%fsD%\0\m\005\0\w\s\scripts | C:\Program Files\FreeFileSync\%fsC%\0\m\005\0\w\s\scripts
As you can see, %mch% expands correctly, but %fs% and %fs2% fail to expand beyond their intermediate values.

Feature Request
I kindly request that FreeFileSync be updated to fully expand indirect environmental variables in Folder Pairs.

Specifically:
Recognize when an environmental variable resolves to another variable and continue expansion until the final value is reached.

Benefits
• Enables consistent and portable synchronization setups across computers with varying drive configurations.
• Enhances compatibility with advanced scripting workflows that rely on indirect environmental variables.
• Aligns FreeFileSync’s handling of environmental variables with the behavior expected in most operating systems.
• This enhancement would greatly improve the flexibility and usability of FreeFileSync, particularly for users managing multiple systems with diverse configurations.

Thank you for considering this request.

— Regards, Sam Katakouzinos
User avatar
Posts: 2615
Joined: 22 Aug 2012

Plerry

Are you sure it is FFS that fails in assigning those indirect variables?
It seems more likely your assignment of fs = %fsE% and fs2 = %fsC% fails.
You can check that e.g. via an echo %fs% and/or echo %fs2% command before you launch FFS.
User avatar
Posts: 4296
Joined: 11 Jun 2019

xCSxXenon

Indirect variables make no sense. Just set %fs% and %fs2% directly to the appropriate values per computer
Posts: 1101
Joined: 8 May 2006

therube

Will %CD% expand as wanted (should return the current directory).
How about %CD:~0,3% (should return the volume "letter").

%CD%, C:\TMP
%CD:~0,3%, C:\
(or D:\ if... hmm, how, will that work ? if you have pairs... that's not going to do it, will it?)


And actually, I'm thinking the above two comments are actually correct.
The variables are not being set correctly, & if you were to just set them (%fs% & %fs2%) directly.
User avatar
Posts: 8
Joined: 18 Jan 2018

samkatakouzinos

Even though it's not mentioned in the v14.0 Release Notes it seems you've made changes that allow indirect environmental variables to become fully expanded.
Thoroughly surprised and happy to open a sync file and see the proper result show and work.
Thank you so much!

— Regards, Sam Katakouzinos
HASS.Agent_5MybtO4p6R.png
HASS.Agent_5MybtO4p6R.png (2.88 KiB) Viewed 701 times
FreeFileSync_x64_zn2KZMeApu.png
FreeFileSync_x64_zn2KZMeApu.png (5.84 KiB) Viewed 701 times
User avatar
Site Admin
Posts: 7357
Joined: 9 Dec 2007

Zenju

it seems you've made changes that allow indirect environmental variables to become fully expanded.
Thoroughly surprised and happy to open a sync file and see the proper result show and work.
Thank you so much! samkatakouzinos, 29 Jan 2025, 13:55
I haven't changed a thing! :D Apparently it has always been this way 🤯 Just tested a few old FFS versions.