Jump to content

Passing user input as variables into script


Recommended Posts

Hello everyone, first off thanks for checking in with this hopeful simple question. 

 

I'm trying to write my first simple workflow that incorporates user input, saves the arguments as variables and then passes them into the script to run. I've debugged it through Alfred and all the variables are coming through fine. The problem comes when I try to run and compile the variables into the script. 

 

Here is the script I'm trying to run:

 

ffmpeg -i {var:file-location} -b {var:v-bitrate} -r {var:frame-rate} -ar {var:sample-rate} -ab {var:a-bitrate}k {var:file-location}

 

Now as I'm a first timer here trying to write something like this, I keep getting the error that says "ffmpeg: command not found" which when I run this in terminal (without the variables of course) runs fine. So I'm presuming that there needs to be a different way to use the variables when applying them to the script, is that correct?

 

Apologies in advance if I'm way off, I've just been wanting to find a way to learn how to create this as I'm getting quite excited about creating different workflows for my needs. Any help is truly appreciated. 

 

Thanks so much!

 

-- MSA

Link to comment
Hi,

 

I've moved this thread to the "Workflow Help & Questions" forum, which is where questions on building workflows belong. The "Discussion & Help" is more for questions about using Alfred.

 

First off, ffmpeg isn't working in Alfred because Mac apps don't use your shell environment, so PATH=/bin:/usr/bin. Use the full path to ffmpeg instead, e.g. /usr/local/bin/ffmpeg

 

Secondly, Alfred doesn't do {var:…} expansion, it sets your variables as environment variables. You probably want something like this:



/usr/local/bin/ffmpeg -i "${file-location}" -b "${v-bitrate}" -r "${frame-rate}" -ar "${sample-rate}" -ab "${a-bitrate}k" "${file-location}"


(Generally, I'd avoid using - in variable names, as it's not allowed in a lot of languages.)

 

Check out the stickied thread on variables for more information.

Edited by deanishe
Link to comment

Good morning and thank you Deanishe - so much. I'll get the hang of the forum space I promise, sorry about that : ).

 

That said, thanks not only for the help but the direction. Happily I can get ffmpeg at least recognized as I better understand the PATH issue. I'll be spending more time with the variables and getting to better understand them. I'm really happy with Alfred and have been wanting to take it up another level for quite some time. Your resources are extremely helpful.

 

Have a great rest of your Afternoon!

 

-MSA

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