-1
  • I use thunar as a file manager
  • I want to use "custom actions" on certain files (Thunar --> Edit --> Configure Custom Actions...)
  • the command I use is: xfce4-terminal -e "md5sum '%F'" --hold

This works fine, except when the file path or file name contains a space. It just won't work as intended because the file can then not be found.

I think this is because the spaces in the file path are not automatically escaped

How do I solve this problem? Thank you in advance

user1557314
  • 169
  • 3
  • 14
  • Try dragging a file from Thunar into your terminal. Many terminal support drag'n'drop like this to get a correctly quoted path automatically. – Socowi Mar 29 '22 at 21:34
  • I'd like to use the option in the context menu through "custom actions". – user1557314 Mar 29 '22 at 22:13
  • Sorry. I thought your action contained a hard-coded file path. In that case you could have quoted that one path using drag-n-drop instead of learning all the rules for quoting. I did not realize, that `%F` is a placeholder that will be replaced by thunar. – Socowi Mar 30 '22 at 00:17

2 Answers2

1

Seems like Thunar replaces %F with (potentially multiple) correctly quoted paths. Putting this inside quotes will ruin the already perfect quoting. From https://docs.xfce.org/xfce/thunar/custom-actions

Never quote field codes

You need a way to pass an argument list to a command running inside xfce4-terminal. Luckily man xfce4-terminal lists:

-x, --execute Execute the remainder of the command line inside the terminal

Therefore, try

xfce4-terminal --hold -x md5sum %F
Socowi
  • 25,550
  • 3
  • 32
  • 54
0

You can easily escape a character with by placing a \ in front of it.

Lou
  • 148
  • 1
  • 12