Jump to content

[SOLVED] Could not read argument names in File Action


Recommended Posts

I have a very simple File Action workflow which reads the filename and also needs two user given inputs.

The workflow I have work done so far is shared here.

 

I was successful to get the name of the input file, but reading the arguments is giving a problem.

 

I apologize in advance, this is a noob question, but it is taking me more than one hours and still no luck.

Edited by Bhishan
Link to post
2 hours ago, Bhishan said:

also needs two user given inputs

 

Alfred's query is one argument. It doesn't matter if there are spaces in it: it's Alfred, not bash.


So this bit is broken:

minute=$1
seconds=$2


If you enter "5 30" as your query, then $1 = 5 30 and $2 is unset.


You need to manually split $1 into its component parts with something like:

mins=$(echo $1 | cut -d' ' -f1)
secs=$(echo $1 | cut -d' ' -f2)

Link to post

Thanks a lot. This worked finally:

 

# Read user given arguments
mins=$(echo "$min_sec" | cut -d' ' -f1)
secs=$(echo "$min_sec" | cut -d' ' -f2)
duration=$( bc -l <<<"60*$mins + $secs" ) # duration in seconds

# Input mp3 file name and output file name
base="${infile%%.mp3}"
output="${base}"_trim.mp3


# Example: /opt/local/bin/ffmpeg -ss 0 -t 120 -i in.mp3 out.mp3
# This will trim from 0 seconds to 120 seconds, i.e. two minutes.
#
#
/opt/local/bin/ffmpeg -ss 0 -t $duration -i "$infile" "$output"



# Practice
# touch "$mins".txt  # This will write a file in directory of this workflow.

 

Edited by Bhishan
Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...