Yuri Posted October 30, 2016 Share Posted October 30, 2016 (edited) Hi, I am a designer and for my job I need sometimes to find a bunch of pictures for my design presentation. I've read several thread regarding this but I think I am still clueless as to how it works. Maybe just need some one to point me to the right direction. What I am looking for: I have a small list (10-15 words) with keywords on txt file: one two three ... ten And there is one site which I want to open in standard browser (safari) with this list of urls: https://www.shutterstock.com/search/one https://www.shutterstock.com/search/two https://www.shutterstock.com/search/three ... https://www.shutterstock.com/search/ten What is the best way to do it? Any help would be appreciated. Edited October 30, 2016 by Yuri Link to comment
vitor Posted October 30, 2016 Share Posted October 30, 2016 (edited) Quite simple to do, you need only loop through each line and tell them to open (when given a URL, this will open in the default browser): IFS=$'\n' # to prevent problems if a line has more than one word separated by spaces for line in $(cat '/path/to/file'); do open "https://www.shutterstock.com/search/${line}" done Made it into a workflow. It uses a File Action, so select the txt file you want and pick quickopen. Give it a try and see if there’s something you’d like a bit differently or a more detailed explanation. Edited October 30, 2016 by vitor Yuri 1 Link to comment
Yuri Posted October 31, 2016 Author Share Posted October 31, 2016 Wow! Thank you! It works well. I am going to buy you a beer :-) How can I add time lag 1-2 seconds between requests? Link to comment
vitor Posted October 31, 2016 Share Posted October 31, 2016 7 hours ago, Yuri said: Wow! Thank you! It works well. I am going to buy you a beer :-) Thank you, I appreciate it. 7 hours ago, Yuri said: How can I add time lag 1-2 seconds between requests? You simply add a sleep 1 (or however many seconds you want) line inside the loop. I’ve uploaded a new version of the workflow that adds a two second delay but also adds URL escaping (in case you ever have non-ASCII characters in your file, it will still work). Yuri 1 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