You are not logged in.
I have custom actions in Thunar for creating relative and absolute symlinks:
ln -sr "%f" '%n (rel link)'
and
ln -s "%f" '%n (abs link)'
However, these actions do not work if the file has spaces in its name. Any suggestions as to how I can handle it, please? (And no, I do not want to use some script that would search the whole system and rename every file that has spaces in its name.)
Last edited by Kzer-Za (2017-08-26 05:15:48)
Offline
I was dealing with similar issue a couple of months ago, and it turned out that this was happening because of incorrect quoting.
Thunar quotes those command parameters under the hood - %f, %n...
I verified this by outputting the result of your command in a file:
echo "ln -sr \"%f\" '%n (rel link)'" > ~/Desktop/out
and the result from the custom action was:
ln -sr "'/home/nick/File with spaces'" ''File with spaces' (rel link)'
As you can see, the second paramter (%n) is incorrectly quoted, because Thunar has added quotes to the file File with spaces, thus breaking your outer quotes.
I think the solution is quite obvious now - you don't need to use any quotes for %f or %n and you need to simply concatenate "(rel link)" and "(abs link)" to the final file name.
So the working versions of the custom actions are as follows:
ln -sr %f %n' (rel link)'
ln -s %f %n' (abs link)'
Offline
Thunar quotes those command parameters under the hood - %f, %n...
So the working versions of the custom actions are as follows:
ln -sr %f %n' (rel link)'
ln -s %f %n' (abs link)'
Thanks!
Offline
[ Generated in 0.013 seconds, 8 queries executed - Memory usage: 521.76 KiB (Peak: 522.38 KiB) ]