I have to align images in a specific way in Photoshop and for that purpose I select a specific number of files (normally 6) in a folder and start the script. This script opens the selected files in Photoshop, merges them into a new document and aligns them. That works fine for me.
But I wondered (and I think it must be possible) to automatise this process a bit. What I would like to have is that I just have to choose an image folder containing let’s say 600 image files and that the script starts at the beginning and always selects six files and starts the process, and after saving the newly created document, it goes on to the next files until it reaches the end of the folder.
Is that possible? As I said, the other stuff works perfect. I need just a kick into the right direction.
on run
set sourceFolder to [path to your folder]
set theFiles to contents of sourceFolder
set filesToEdit to {}
repeat with i from 1 to count of theFiles
if count of filesToEdit is less than 6 then
set filesToEdit to filesToEdit and & {item i of theFiles}
else
my alignFilesInPhotoshop(filesToEdit)
set filesToEdit to {}
end if
end repeat
end run
on alignFilesInPhotoshop(someFiles)
(* Put your existing script here *)
end alignFilesInPhotoshop
thanks a lot. Your script was very helpful. I included my own script that in principle just operates Photoshop and starts specific actions. My first tests were successful, but it needs some refurbishing.
Thanks a lot.
tell application "Finder"
set sourceFolder to choose folder
set FolderName to "Archival1"
set destinFolder to (make new folder at sourceFolder with properties {name:FolderName})
set theFiles to contents of sourceFolder
repeat with i from 1 to 3
select (first file of sourceFolder whose name contains "be")
set theSelection to first item of (get selection)
set {theName, theExtension} to {name, name extension} of theSelection
if theExtension is not "" then
set theName to text 1 thru -((count theExtension) + 2) of theName -- just
set theExtension to "." & theExtension
end if
set museumNo to text 1 thru -4 of theName
select (every file of sourceFolder whose name contains museumNo)
set finderitems to selection
tell application "Adobe Photoshop CS5"
activate
set background color to {class:RGB color, red:0, green:0, blue:0}
set docRef to make new document with properties {width:5000 as pixels, height:8000 as pixels, resolution:600, initial fill:use background color}
set current document to docRef
repeat with i from 1 to number of items in finderitems
set this_item to item i of finderitems as string
open file this_item
do action "SELECT" from "FATCROSS"
tell current document
paste
end tell
end repeat
tell current document
do action "RENAME" from "FATCROSS"
do action "ALIGN_scan" from "FATCROSS"
end tell
save current document in file ((sourceFolder & museumNo) as string) as TIFF with options {class:TIFF save options, byte order:IBM PC, embed color profile:false, image compression:none, save alpha channels:false, save layers:false, interleave channels:true} appending lowercase extension with copying
end tell
tell application "Finder"
repeat with anItem in finderitems
move anItem to destinFolder
end repeat
end tell
end repeat
end tell