Edit: let me ask my question differently.
Hi,
I have a USB-Stick on my keychain with several folders that I want to sync to a SFTP for mostly backup purposes.
So I placed a sync.ffs_gui in each folder.
In that ffs_gui I wrote "./" as a relative path that should point to the folder where the file is in (after double-click-opening).
Under Windows this works.
Under Linux Mint it resolves to the home folder.
Is this a bug or should I use a different path so it works under both Linux and Windows?
Synchronizing folders relative to sync.ffs_gui
- Posts: 4
- Joined: 1 Aug 2023
- Posts: 4
- Joined: 1 Aug 2023
I found a workaround.
Create a file like sync.sh, make it executable and in it you write "freefilesync sync.ffs_gui".
Then it is launching with the correct working directory.
I tried to fix /usr/share/applications/FreeFileSync.desktop but there is something wrong not related to FFS.
Ther are some whacky solutions on the internet but most fail if theres a space in the path and they cause all sorts of other problems.
Create a file like sync.sh, make it executable and in it you write "freefilesync sync.ffs_gui".
Then it is launching with the correct working directory.
I tried to fix /usr/share/applications/FreeFileSync.desktop but there is something wrong not related to FFS.
Ther are some whacky solutions on the internet but most fail if theres a space in the path and they cause all sorts of other problems.
- Site Admin
- Posts: 7211
- Joined: 9 Dec 2007
Indeed, the working directory is not set on Linux the same way as it is done on Windows when you double-click on a ffs_gui file.
Update: Apparently this doesn't work when there are spaces in the file paths.
The following might be a workaround for FreeFileSync.desktop:I tried to fix /usr/share/applications/FreeFileSync.desktop but there is something wrong not related to FFS. CarstenF, 03 Aug 2023, 11:59
Exec=/bin/bash -c 'FFS_ARG="%f"; cd "$(dirname "$FFS_ARG")"; "/opt/FreeFileSync/FreeFileSync" "$FFS_ARG"'
- Posts: 4
- Joined: 1 Aug 2023
I was at that point too, this does not work if a space is in the path.
- Site Admin
- Posts: 7211
- Joined: 9 Dec 2007
The desktop file's "Exec" is parsed once before the command is executed, so we need some escaping. The following version should do the trick:
Some implementation details about Exec I found out:
• either %f or %F is replaced, and exactly once
• %f is replaced by file path with single quotes if path contains spaces. (This is why the Exec example above must start with double quotes)
• %F is replaced by a list of single-quoted paths if spaces occur inside them.
Exec=/bin/sh -c "filePath=%f; cd \"$(dirname \"$filePath\")\"; /opt/FreeFileSync/FreeFileSync \"$filePath\""
• either %f or %F is replaced, and exactly once
• %f is replaced by file path with single quotes if path contains spaces. (This is why the Exec example above must start with double quotes)
• %F is replaced by a list of single-quoted paths if spaces occur inside them.
- Posts: 4
- Joined: 1 Aug 2023
YES, that works.
Thank you.
I'll make
of it, because if I open FFS via desktop shortcut by accident I might overwrite my backup with my home folder data. Would be nice if there was an option not to save that file automatically.
Thank you.
I'll make
Exec=/bin/sh -c "filePath=%f; cd \"$(dirname \"$filePath\")\"; /opt/FreeFileSync/FreeFileSync \"$filePath\"; rm ~/.config/FreeFileSync/LastRun.ffs_gui"
- Site Admin
- Posts: 7211
- Joined: 9 Dec 2007
Here's an improved version using bash arrays. In addition to single file path arguments it works with:
• multiple path arguments
• zero arguments
Example: Exec will make bash execute a command like the following:
Update 2023-09-16: Apparently the syntax does not work on all Linux systems, e.g. it fails with a syntax error on WSL2 and on Kubuntu: viewtopic.php?t=10666
• multiple path arguments
• zero arguments
Exec=/bin/bash -c "paths=(%F); cd \"\$(dirname \"\${paths[0]}\")\"; /opt/FreeFileSync/FreeFileSync \"\${paths[@]}\" "
paths=('folder/spaced file.txt'); cd "$(dirname "${paths[0]}")"; /opt/FreeFileSync/FreeFileSync "${paths[@]}"