Xfce Forum

Sub domains
 

You are not logged in.

#1 2015-08-08 15:02:10

akovia
Member
Registered: 2011-03-27
Posts: 60

Custom Action Trouble

Hi,
I have been using a bash script I found a while back to create a playlist via custom action.
This works well for creating a recursive playlist, but I am trying to modify it to only create a playlist from the selected items only. It seemed to me I should only have to change the %D to %F and use the same script, but it will only create a playlist from the first item selected.
I'm hoping I'm just overlooking something simple, but I'm stumped.

Here are the custom actions:

<action>
	<icon>playlist</icon>
	<name>Create Playlist Recursive</name>
	<unique-id>1438391983211903-5</unique-id>
	<command>xfce4-terminal -H -x ~/bin/m3u_maker_TA.sh %D</command>
	<description>m3u playlist of all playable media - edit script to shuffle</description>
	<patterns>*</patterns>
	<directories/>
	<audio-files/>
	<image-files/>
	<other-files/>
	<video-files/>
</action>
<action>
	<icon>audio-x-mp3-playlist</icon>
	<name>Create Playlist Selected</name>
	<unique-id>1438971384287455-8</unique-id>
	<command>xfce4-terminal -H -x ~/bin/m3u_maker_TA.sh %F</command>
	<description></description>
	<patterns>*</patterns>
	<audio-files/>
	<image-files/>
	<other-files/>
	<video-files/>
</action>

..and the bash script.

#!/bin/bash
# Creates M3U from all media files recursively as a thunar action.
set -x
touch "${PWD##*/}.m3u"
export IFS=$'\n'
# flac, ape, wv, wav, mp3, aac, ogg, oga, wma, mpc, m4a, mp4,
# mkv, mpg, avi, mpeg, webm, flv, wmv, m4v, 3gp, rm, rmvb, ifo
# mov, vob, asf, ogm, m2v, avc, dv, pg, jpeg, bmp, png, gif
for i in $(find $1 -name "*" -type f|egrep *.'[fF][lL][aA][cC]|[aA][pP][eE]|/
[wW][vV]|[wW][aA][vV]|[mM][pP][3]|[aA][aA][cC]|[oO][gG][gG]|[oO][gG][aA]|/
[wW][mM][aA]|[mM][pP][cC]|[mM][4][aA]|[mM][pP][4]|[mM][kK][vV]|[mM][pP][gG]|/
[aA][vV][iI]|[mM][pP][eE][gG]|[wW][eE][bB][mM]|[fF][lL][vV]|[wW][mM][vV]|/
[mM][4][vV]|[3][gG][pP]|[rR][mM]|[rR][mM][vV][bB]|[iI][fF][oO]|[mM][oO][vV]|/
[dD][iI][vV][xX]|[vV][oO][bB]|[aA][sS][fF]|[oO][gG][mM]|[mM][2][vV]|/
[aA]vV][cC]|[dD][vV]|[jJ][pP][gG]|[jJ][pP][eE][gG]|[pP][nN][gG]|[bB][mM][pP]|/
[gG][iI][fF]' )
do 
echo "$i"|sed 's/^.*\.m3u//' >> "${PWD##*/}.m3u"
done

# Uncomment next 3 lines to shuffle playlist

#shuf "${PWD##*/}.m3u" > "${PWD##*/}2.m3u"
#shuf "${PWD##*/}2.m3u" > "${PWD##*/}.m3u"
#rm "${PWD##*/}2.m3u"

any help is most appreciated.


Arch Linux

Offline

#2 2015-08-08 17:17:55

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,485

Re: Custom Action Trouble

akovia wrote:
for i in $(find $1 -name.....

When a thunar custom action sends over a number of parameters (more that one file), each file gets a different positional parameter (e.g. $1, $2, $3, etc). All of the parameters can be retrieved via $@.

The script that you are using is only searching for the first parameter ($1) and will never see or process the other sent parameters. This works fine in a situation where there is only one parameter (the name of a directory), but fails when more than one parameter is sent.

A quick fix is to change the "$1" to read "$@" so that all parameters are processed.


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 2015-08-08 19:59:20

akovia
Member
Registered: 2011-03-27
Posts: 60

Re: Custom Action Trouble

Wow!
I can't believed I missed that.
I really appreciate the quick reply. That was driving me insane.

Cheers


Arch Linux

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.011 seconds, 8 queries executed - Memory usage: 541.53 KiB (Peak: 542.81 KiB) ]