winterflags Posted September 11, 2016 Share Posted September 11, 2016 (edited) Hello everyone! I've started working on an Alfred workflow that's supposed to take a Finder item, and search for its filename on the web (preferably on a specific site using Google). My thought was to use the File Filter to select the file in Finder, and then use the Action menu to open my workflow. It should then just be a matter of passing the filename to Open URL along the pattern of: https://www.google.com/search?q={query}%20site%3Amyhomepage.com But how do I get the filename and create a query out of it? Is there an easy way to do this using Alfred's native tools, or is a Bash/AppleScript/etc solution necessary? Advanced: What if I want to add some conditional rules, like removal of substrings or extension from the filename? (I'm still happy with just the basic functionality though)… Thanks! Edited September 11, 2016 by winterflags Link to comment
deanishe Posted September 11, 2016 Share Posted September 11, 2016 Create a File Action (or File Filter) and connect it to a Run Script Action with Language = /bin/bash and with input as argv (i.e. the defaults). Put this in the Script box: basename "$1" That will print the, well, basename (the bit after the last /) of the actioned file. Connect that to your Open URL Action and you're good to go. Link to comment
winterflags Posted September 11, 2016 Author Share Posted September 11, 2016 (edited) Create a File Action (or File Filter) and connect it to a Run Script Action with Language = /bin/bash and with input as argv (i.e. the defaults). Put this in the Script box: basename "$1" That will print the, well, basename (the bit after the last /) of the actioned file. Connect that to your Open URL Action and you're good to go. Perfect – it works. Alfred is such a great tool. Thanks! Edited September 11, 2016 by winterflags 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