Xfce Forum

Sub domains
 

You are not logged in.

#1 2016-12-18 06:19:40

thebunnyrules
Member
Registered: 2016-12-18
Posts: 9

Saving the output to a file when launching xfce4 terminal when using a

I'm trying to setup a custom action for thunar (these are the custom context menu commands) that will map all the files within the folder structure I'm in.

If I was in terminal, all I'd have to do is input the following command while I'm within the directory I want to map:

    find . -type f > content.txt

To map this as a custom action, I tried the following command

    xfce4-terminal --working-directory=%d --command='find . -type f > %d/content.txt'

and it doesn't work, despite that fact that this one which is almost the same does work:

    xfce4-terminal --hold --working-directory=/home/lapinot/Downloads/%d -command='find . -type f'

The only notable difference between the two is that I'm trying to feed the outcome into a text file via `>` switch in the one that isn't working.

Anyone has any ideas how I can get this to work? Note that %d is referring to the directory I'm in in thunar.

Offline

#2 2016-12-18 14:07:58

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,948

Re: Saving the output to a file when launching xfce4 terminal when using a

Hello and welcome.

The Thunar custom actions interpreter is not the same or as robust as a shell interpreter. Therefore, items like the pipe command '>' are not processed. To get them to work, you need to en-case them in a shell interpreter. Wrap your command in a 'bash -c "<YOUR COMMAND>" call.

Something like this:

bash -c "find %f -type f > %f/content.txt"

... (with directories only selected in the Appearance tab, will allow you to run the custom action on a selected directory and drop the resulting file inside that selected directory.

If you want to run the custom action against a file or directory inside the directory that you want the contents file in, use:

bash -c "find %d -type f > %d/content.txt"

...with everything selected in the Appearance tab.

To get it to run using xfce4-terminal (As in your examples above), en-case the command part in a bash shell:

xfce4-terminal --working-directory=%d --command='bash -c "find . -type f > %d/content.txt"'

Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#3 2016-12-19 05:26:21

thebunnyrules
Member
Registered: 2016-12-18
Posts: 9

Re: Saving the output to a file when launching xfce4 terminal when using a

Hehe, fellow Canadian! smile Thanks for the quick response. I tried the last line you gave me:

xfce4-terminal --working-directory=%d --command='bash -c "find . -type f > %d/content.txt"'

and it worked like a charm when I have a directory selected but not when I right click the background of the directory I'm in and try to run it from the contextual menu. I selected directories only under appearance condition with a * for the File Pattern. Did I do something wrong or is that just a limitation of Thunar?

Last edited by thebunnyrules (2016-12-19 05:27:33)

Offline

#4 2016-12-19 11:27:06

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,948

Re: Saving the output to a file when launching xfce4 terminal when using a

And hello to you fellow bundled-up Canadian (brrrr).

Try using %f instead of %d in that string:

xfce4-terminal --working-directory=%f --command='bash -c "find . -type f > %f/content.txt"'

If you create a "Debug Variables" custom action with the following command:

zenity --info --text="f=%f\nF=%F\nd=%d\nD=%D\nn=%n\nN=%N"

...(note that you need to have zenity installed), you can get a view into what those variables translate to. The %d was translating to the directory containing the current directory, and creating the file there.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#5 2016-12-19 14:23:16

thebunnyrules
Member
Registered: 2016-12-18
Posts: 9

Re: Saving the output to a file when launching xfce4 terminal when using a

Brrr, indeed, it's -20oC in Montreal today!!! smile

Thanks so much, Toz, %f works perfectly!!!

Offline

Board footer

Powered by FluxBB