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 comment
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 comment

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 comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...