• 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
Apply script to subfolders, save file to new folder
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Apply script to subfolders, save file to new folder


  • Subject: Apply script to subfolders, save file to new folder
  • From: Ruta <email@hidden>
  • Date: Wed, 20 Dec 2006 00:59:53 -0800 (PST)

Hi all,

I have a bunch of image files in jpg format.  They're in a collection
of folders and subfolders.  I received the below AppleScript which does
the following:

1. converts them to psd via Photoshop CS 1
2. changes the size but keeps the same proportions (ie, the script
identifies the longest side of the image -- horizontal or vertical --
and resizes based off it)

The script is great.  But in addition to the above, I want the script
to:

3. apply to all files in all SUBFOLDERS.  Right now, it applies only to
files in the top level of the folder I select at the beginning of the
script.
4. save the converted files to a NEW FOLDER, which I identify at the
beginning of the script.  Right now, the script saves the psd files to
the same location as the jpg files.

This is where I am stuck.  I've twiddled around with the script.  But
I'm a newbie with AppleScript, and I have not been able to get 3 and 4
to work.

If it's not asking too much, could someone give me the code to do 3 and
4?

(Apparently there are Tiger Automator scripts that work with Photoshop
CS to achieve the above, but I am still on Panther.)

Thanks a lot for your help!

---------------

on resize(y)

--get rid of .jpg or .jpeg at the end of file name
if y ends with ".jpg" then
set new_y to (characters 1 thru -5 of y) as string
else if y ends with ".jpeg" then
set new_y to (characters 1 thru -6 of y) as string
else
set new_y to y
end if

--set new file name using .psd extension
set new_y to new_y & ".psd"

tell application "Adobe Photoshop CS2" --change as needed
activate --if you want to watch PS do it's thing
open file y
set x to current document

--get dimensions of current photo
set w to width of x
set h to height of x

--calculate new dimensions based on longest side
if w > h then
set new_w to 1500
set new_h to round (h * (1500 / w))
else
set new_h to 1500
set new_w to round (w * (1500 / h))
end if

--resize current document
resize image x width new_w height new_h

--save it as a Photoshop file (.psd)
save current document in file new_y as Photoshop format appending no
extension
close current document

end tell
end resize

tell application "Finder"
activate
set f to (choose folder with prompt "Select folder of photos to
convert")

--get every jpeg file in the selected folder
set fls to (every file of folder f whose file type is "JPEG")
repeat with a in fls
--send to resize subroutine
my resize((f & name of a) as string)
end repeat
end tell

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
 _______________________________________________
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/mailman//archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Apply script to subfolders, save file to new folder
      • From: Michelle Steiner <email@hidden>
  • Prev by Date: Re: Applescript mounting servers and finder
  • Next by Date: FINAL SAMPLE - get every document file of every folder of startup disk
  • Previous by thread: Re: Help with move file script
  • Next by thread: Re: Apply script to subfolders, save file to new folder
  • Index(es):
    • Date
    • Thread