Jump to content

Run script : getting in your script the path of the file you want to run the script against.


Recommended Posts

After literally hours, I finally find a solution to add a drop shadow effect on a given .png file.

 

The "one-liner" I found is working as I could make it work in zsh (cf. the image below).

 

The problem I have is I do not know how to make it work in a file action with a run script action.

 

I simply attached a file action to this run script action. 

 

 Run_Script_Screenshots.png.dcb6bfe77190b70bfddc821d461b09e4.png 

 

My question is: how do I do for Alfred to get the value /PathToMyFile.png which is the path of the file I want to add the drop shadow effect?

 

Thank you.

Link to comment

“With input as argv” means the filepath(s) are passed to your script as command-line arguments. In shell, you access them with $1, $2 etc.

 

So you replace "PathToMyFile.png" with "$1".

 

I’d be surprised if that script actually works, since convert isn’t a standard command. Normally, you’d need to specify its full path, i.e. /usr/local/bin/convert.

Link to comment
  • 2 weeks later...

1°) Sorry for the late reply I didn't see any notification about your answer. Thank you for the precision about "argv". Makes me understand a little bit more about how Alfred works with scripts. 

 

2°) I changed the script to: 

 

Quote

/usr/local/bin/convert "$1" -bordercolor white -border 5 \( +clone -background black -shadow 80x3+2+2 \) +swap -background white -layers merge +repage "$1"

 

It is now working like a charm!

 

Thank you!

 

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