Resize Image and Rename from Clipboard

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Resize Image and Rename from Clipboard Mon Mar 05, 2018 8:35 am • by lukemccoy
I'm trying to automate the following:

1. I download a stock photo from Adobe Stock photos.
2. I move it to my stock photo folder.
3. Make a copy.
4. Move that over to another folder.
5. Resize it to 1200 width.
6. Rename it to the slug/url that I'm using in the article it is being used with (ie. sample-article-url)

I have most of this working except for the renaming part. I'm not familiar with Apple Script and what I found searching didn't seem to work.

I currently have this setup running on my Downloads folder:

If the file starts with AdobeStock then:

1. Move it to Stock Images folder.
2. Copy to Article Images folder.
3. Run Apple Script:

Code: Select all
tell application "Image Events"
   set this_image to open theFile
   set imageDimensions to dimensions of this_image
   if item 1 of imageDimensions > 1200 then
      scale this_image to size 1200
      save this_image in theFile
   end if
   
   close this_image
end tell


I just need to get it to rename the file to whatever I have in my clipboard. So then I would get the article ready, copy the url I want to use into the clipboard, go find the photo I want to use, download it and then the image will be properly resized and renamed in my Article Images folder but also have a copy of the original stock photo in my Stock Photos folder.
lukemccoy
 
Posts: 4
Joined: Wed Jun 01, 2016 5:55 pm

Re: Resize Image and Rename from Clipboard Mon Mar 05, 2018 11:57 am • by Mr_Noodle
This type of thing is beyond the help I can provide. You might want to check out AppleScript sites out there on how to grab text from the clipboard and apply that.

Note that as an alternative to renaming the file in your script, you can transmit the name on the clipboard back to Hazel. Check Hazel's section on AppleScript. There it will explain how you can create output attributes which you can then use in subsequent actions.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support