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

Re: Apply script to subfolders, save file to new folder


  • Subject: Re: Apply script to subfolders, save file to new folder
  • From: Ruta <email@hidden>
  • Date: Fri, 22 Dec 2006 07:52:59 -0800 (PST)

Thanks a lot, Michelle, for your help.  I integrated your subfolder
part and the new script works well.  It is below.


> 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.

> If we saw how you're doing it now, it would help to tell you what to
>
> change.  Someone else probably would have to do that because I don't
>
> have Photoshop, so I've never scripted it.

Sorry my explanation was not clear.  Right now the script converts psd
files to jpg files and saves those jpg files to the same folder that
the psd files were in.  That is what the script is doing now.  It would
be much better for me, though, if the jpg files were saved to a
different folder.  That different folder could be hard coded in the
script, or it could be one that the script allows me to specify via a
dialog.  Either way is OK with me.  The key thing is that the jpgs are
saved to one new folder.

Again, thank you very much for the help.


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

on resize(y)

	--get rid of .jpg or .jpeg at the end of file name
	if y ends with ".psd" then
		set new_y to (characters 1 thru -5 of y) as string
	else if y ends with ".tif" then
		set new_y to (characters 1 thru -5 of y) as string
	else if y ends with ".tiff" 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 .jpg extension
	set new_y to new_y & ".jpg"


	tell application "Adobe Photoshop CS" --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 JPG file (.jpg)
		save current document in file new_y as JPEG appending no extension
		close current document

	end tell
end resize


set topLevel to (choose folder with prompt "Select folder of photos to
convert to jpg and resize. Subfolders will be included.")
splitFoldersFromFiles(topLevel)

on splitFoldersFromFiles(inputFolder)
	tell application "Finder"
		my processFiles(get files of inputFolder)
		set FolderList to folders of inputFolder
		repeat with thisFolder in FolderList
			my splitFoldersFromFiles(thisFolder)
		end repeat
	end tell
end splitFoldersFromFiles

on processFiles(FileList)
	repeat with thisFile in FileList
		my resize((thisFile) as string)
	end repeat
end processFiles

__________________________________________________
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>
References: 
 >Re: Apply script to subfolders, save file to new folder (From: Michelle Steiner <email@hidden>)

  • Prev by Date: Tools for vim fanatics: RunVim, applescript.vim
  • Next by Date: Re: Apply script to subfolders, save file to new folder
  • Previous by thread: Re: Apply script to subfolders, save file to new folder
  • Next by thread: Re: Apply script to subfolders, save file to new folder
  • Index(es):
    • Date
    • Thread