• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Newbie needs help
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Newbie needs help


  • Subject: Re: Newbie needs help
  • From: Brian Christmas <email@hidden>
  • Date: Sun, 15 Mar 2009 20:23:06 +1100


G'day Omar

This should work.

Regards

Santa


property theFolder : "Web Images"
global PathToDesktop

set PathToDesktop to path to desktop
tell application "Finder"
activate
try
make new folder with properties {name:theFolder} at desktop
on error
display dialog "There is already a folder named “" & theFolder & "” on your desktop. Would it be okay to use it?"
end try
set folder_names to {"Large", "Medium", "Small", "Icon"}
repeat with folder_name in folder_names
try
make new folder with properties {name:folder_name} at folder "Web Images"
on error
display dialog "There is already a folder named " & folder_name & " in the folder “" & theFolder & "” on your desktop. Would it be okay to use it? All images with the same name will be replaced."
end try
end repeat
end tell


tell application "Finder"
activate
set these_files to choose file without invisibles
end tell
set the target_lengths to {400, 250, 120, 79}
repeat with target_length in target_lengths
set folder_names to {"Large", "Medium", "Small", "Icon"}
repeat with folder_name in folder_names
set jpeg_sizes to {"_Large", "_Medium", "_Small", "_Icon"}
repeat with jpeg_size in jpeg_sizes
try
tell application "Finder"
set the new_name to my add_extension(these_files, "jpg")
if (exists file new_name of folder folder_name of folder theFolder) then
display dialog "A file named \"" & new_name & "\" already exists."
end if
set thePath to (PathToDesktop & theFolder & ":" & folder_name & ":" & new_name) as text
end tell
tell application "Image Events"
launch
set this_image to open these_files
copy dimensions of this_image to {w, h}
scale this_image to size target_length
set new_image to save this_image as JPEG in file thePath with icon
close this_image
end tell
on error error_message
display dialog error_message
end try
end repeat
end repeat
end repeat

on add_extension(these_files, new_extension)
set this_info to the info for these_files
set this_name to the name of this_info
set this_extension to the name extension of this_info
set jpeg_sizes to {"_Large", "_Medium", "_Small", "_Icon"}
repeat with jpeg_size in jpeg_sizes
if this_extension is missing value then
set the default_name to this_name
else
set the default_name to text 1 thru -((length of this_extension) + 2) of this_name
end if
return (the default_name & jpeg_size & "." & the new_extension)
end repeat
end add_extension

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Newbie needs help (From: Omar Khatib <email@hidden>)

  • Prev by Date: Newbie needs help
  • Next by Date: Re: Newbie needs help
  • Previous by thread: Newbie needs help
  • Next by thread: Re: Newbie needs help
  • Index(es):
    • Date
    • Thread