What I mean is that on several occasions I was able to successfully run a command in a terminal window opened in a certain folder, but when using a command (run not directly from terminal, but from a Thunar custom action) to do the same - that is: open a terminal in the same folder and run the same initial command - it would not work as expected.

For example, I have a folder that contains a pdf file. I want to save the pdf pages as images.

CASE 1: I open a terminal in that folder and run this command: pdftoppm -png *.pdf prefix. The pdf pages are extracted as png files.

CASE 2: I try to do the same from Thunar custom actions. I create a custom action with the command xfce4-terminal -e "pdftoppm -png *.pdf prefix", Appearance conditions; Directories, but that does nothing. To get more details, it is useful to keep that terminal window open after the command is run, but I do not know how to do that with the Xfce terminal. Using gnome-terminal I create a profile called new1 with the setting "When command exits: Hold the terminal open" then add to custom action this command:

gnome-terminal --window-with-profile=new1 -e "pdftoppm -png *.pdf prefix"

But this gives an error:

I/O Error: Couldn't open file '*.pdf': No such file or directory.

What is the difference between CASE 1 and CASE 2 which triggers the different results?

I have an answer to the question Thunar - Custom actions: save selected pdf as images. The command that works in Thunar custom actions is pdftoppm %f -png %f.png.

But I am curious why a command works in terminal but a different command that opens the terminal and runs that command does not.

  • May be you are missing --working-directory which should be one that containing *.pdf (i.e open terminal here not satisfied) – Pandya Nov 10 '14 at 16:20
  • %f required to selection of files visit this and this can help – Pandya Nov 10 '14 at 16:27
  • @Pandya : thunar action command xfce4-terminal will open the terminal in the folder where the action is run, and there is no error in this way. i was expecting a thunar action command like xfce4-terminal -e <command> to run also <command>in the folder where the action is run, in the same way as when running <command> in the terminal window opened with 'open terminal here' (which works, as tested) – user47206 Nov 10 '14 at 16:57
  • @Pandya - when i get that error message I do not intend to select the file, just run the command in the specific folder – user47206 Nov 10 '14 at 17:14

On my system, the Thunar custom actions seem to call the command with bash and makes the use of xfce4-terminal superfluous.

Try the following action instead:

cd %f && pdftoppm -png *.pdf prefix

enter image description here

You get the I/O Error: Couldn't open file '*.pdf': No such file or directory. message as your selection is now a directory and the current directory is then one level up.

So you need to first cd into the target before running the pdftoppm command.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy