-- Created by Mike Rapin -- -- last updated 6/16/2008 -- -- drag files to the application's icon in -- -- Finder to begin resizing/moving -- on open some_items -- change this to whatever height you want your images scaled to set desiredHeight to 800 tell application "Finder" -- grabs the current user set currentUser to (system attribute "USER") -- creates folder "original_walls" if it doesn't exist in your Pictures folder if not (exists folder "original_walls:" of ("Macintosh HD:Users:" & currentUser & ":Pictures:" as alias)) then make new folder at ("Macintosh HD:Users:" & currentUser & ":Pictures:" as alias) with properties {name:"original_walls"} end if -- creates folder "wallpaper" if it doesn't exist in your Pictures folder if not (exists folder "wallpaper:" of ("Macintosh HD:Users:" & currentUser & ":Pictures:" as alias)) then make new folder at ("Macintosh HD:Users:" & currentUser & ":Pictures:" as alias) with properties {name:"wallpaper"} end if -- sets the name of a new folder based on the month and year -- ex: 6-2008 set new_foldername to ((month of the (current date)) as integer as string) & "-" & ((year of the (current date)) as integer as string) set this_folder to ("Macintosh HD:Users:" & currentUser & ":Pictures:wallpaper" as alias) -- If the month folder doesn't exist in your wallpaper folder, create it. if not (exists folder new_foldername of this_folder) then make new folder at this_folder with properties {name:new_foldername} end if end tell -- loops through all of the images dropped on the application and resizes them repeat with this_item in some_items try rescale_and_save(this_item, desiredHeight) end try end repeat end open to rescale_and_save(this_item, desiredHeight) tell application "Image Events" launch -- the target height at which you want your wallpaper to be at set the target_height to desiredHeight -- open the image file set this_image to open this_item set typ to this_image's file type copy dimensions of this_image to {current_width, current_height} if current_height is greater than current_width then scale this_image to size target_height else -- figure out new height -- y2 = (y1 * x2) / x1 set the new_height to (current_width * target_height) / current_height scale this_image to size new_height end if tell application "Finder" -- Checks for a folder named [month number]-[year] in a folder -- called "wallpaper" in your Pictures folder -- ex: 6-2008 set currentUser to (system attribute "USER") set new_foldername to ((month of the (current date)) as integer as string) & "-" & ((year of the (current date)) as integer as string) set this_folder to ("Macintosh HD:Users:" & currentUser & ":Pictures:wallpaper" as alias) set monthFolder to ((this_folder as string) & new_foldername) as alias -- Sets the name of the new item, then tries to save it. -- If the save fails for some reason it displays the location -- of your month folder... (It really shouldn't fail...) set new_item to ¬ (monthFolder as string) & "scaled." & (name of this_item) try save this_image in new_item as typ on error display dialog "dood wtf? -> " & (monthFolder as string) end try move this_item to "Macintosh HD:Users:" & currentUser & ":Pictures:original_walls:" end tell end tell end rescale_and_save