Xfce Forum

Sub domains
 

You are not logged in.

#1 2017-08-26 05:14:51

Kzer-Za
Member
Registered: 2017-03-18
Posts: 7

Thunar custom action for creating symlinks to files with spaces

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

#2 2017-08-28 10:53:23

PaperNick
Member
From: Bulgaria
Registered: 2013-05-26
Posts: 74

Re: Thunar custom action for creating symlinks to files with spaces

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

#3 2017-08-28 12:40:28

Kzer-Za
Member
Registered: 2017-03-18
Posts: 7

Re: Thunar custom action for creating symlinks to files with spaces

PaperNick wrote:

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

Board footer

Powered by FluxBB