The Problem
Hi guys and Gals! I’m trying :rolleyes: to modify Cristos excellent script so it opens all the files in a folder sequentially (they are numerical named 1 thru to 14) then processes them with the Photoshop action and then saves them to the predetermined folder. Before moving on to process the next folder.
Anyone got any ideas?
--This AS is made by Christopher Wiedswang, cristo@online.no. It´s put together with bits and pieces found around...
set deliMiter to AppleScript's text item delimiters
property dialog_timeout : 30 -- set the amount of time before dialogs auto-answer.
set alert_message to "Select folder to process:"
display dialog the alert_message buttons {"Cancel", "OK"} default button 2 with icon 1 giving up after dialog_timeout
set inputFolder to choose folder
set alert_message to "Select folder to save processed folders in:"
display dialog the alert_message buttons {"Cancel", "OK"} default button 2 with icon 1 giving up after dialog_timeout
set outputFolder to choose folder
tell application "Finder"
set folderList to folders in inputFolder
end tell
repeat with aFolder in folderList
set AppleScript's text item delimiters to ""
set toThis to aFolder as string
if the toThis ends with ":" then
set the toThru to ((the number of characters of the toThis) - 1)
set toThis to (characters 1 thru toThru of toThis) as string
end if
if the toThis contains ":" then
set AppleScript's text item delimiters to {":"}
set toThis to get last text item of toThis
set AppleScript's text item delimiters to deliMiter
end if
tell application "Finder"
set filesList to files in aFolder
if (not (exists folder ((outputFolder as string) & toThis))) then
set suboutputFolder to make new folder at outputFolder with properties {name:toThis}
else
set outputFolder to folder ((outputFolder as string) & toThis)
end if
end tell
tell application "Adobe Photoshop 7.0"
set display dialogs to never
close every document saving yes
end tell
repeat with aFile in filesList
tell application "Finder"
-- The step below is important because the 'aFile' reference as returned by
-- Finder associates the file with Finder and not Photoshop. By converting
-- the reference below 'as alias', the reference used by 'open' will be
-- correctly handled by Photoshop rather than Finder.
set theFile to aFile as alias
set theFileName to name of theFile
end tell
tell application "Adobe Photoshop 7.0"
set startRulerUnits to ruler units of settings
set ruler units of settings to pixel units
open theFile
set docRef to current document
--Her goes your actions, you have to change "imageSizeB" and "Applescript" with your action name("imageSizeB") and from folder set("Applescript")
do action "Sepia Toning (layer)" from "Default Actions"
-- Convert the document to a document mode that supports saving as jpeg
if (bits per channel of docRef is sixteen) then
set bits per channel of docRef to eight
end if
set docName to name of docRef
set docBaseName to getBaseName(docName) of me
set newFileName to (suboutputFolder as string) & docBaseName
-- This is the saving properties, which saves as JPEG, quality 12
set myOptionsJPG to ¬
{class:JPEG save options, embed color profile:true, format options:standard, matte:none, quality:12}
save docRef in file newFileName as JPEG with options myOptionsJPG appending lowercase extension with copying
close current document without saving
end tell
end repeat
end repeat
set the date_stamp to ((the current date) as string)
set alert_message to "The job is done at " & date_stamp & ", I´m waiting for more..." as Unicode text
display dialog the alert_message buttons {"Show me", "No thanks"} default button 2 with icon 1 giving up after dialog_timeout
set the user_choice to the button returned of the result
if user_choice is "Show me" then
tell application "Finder"
--go to the desktop
activate
--open the folder
open outputFolder
end tell
end if
-- Returns the document name without extension (if present)
on getBaseName(fName)
set baseName to fName
repeat with idx from 1 to (length of fName)
if (item idx of fName = ".") then
set baseName to (items 1 thru (idx - 1) of fName) as string
exit repeat
end if
end repeat
return baseName
end getBaseName
Cheers for taking the time to help me.
TimP
Model: G4 733 Quicksilver
AppleScript: 1.9.3
Browser: Safari 312
Operating System: Mac OS X (10.3.9)