Bhishan Posted May 13, 2018 Share Posted May 13, 2018 (edited) 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 May 15, 2018 by Bhishan Link to comment
deanishe Posted May 14, 2018 Share Posted May 14, 2018 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) Bhishan 1 Link to comment
Bhishan Posted May 14, 2018 Author Share Posted May 14, 2018 (edited) 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 May 14, 2018 by Bhishan Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now