Hi All
I have a script for Photoshop that works “ once! On the second time around I get a message:
Does anyone have any idea why this is happening? Also feel free to give me any ideas how to improve this script. If it’s any use to you then enjoy!
# merges layers within a specified group. At present it only works on top level groups.
global thisDoc
global groupToTidy
on run
display dialog "This script will merge all layers within a group you name. You must specify the name exactly and choose one or more Photoshop files to process." default answer "Group name"
set groupToTidy to text returned of result
set thesefiles to choose file with multiple selections allowed
tell application "Adobe Photoshop CS5.1"
activate
set display dialogs to never
repeat with thisfile in thesefiles
open thisfile
set thisDoc to the current document
log groupToTidy
my mergeLayers()
save thisDoc
close thisDoc
end repeat
set display dialogs to always
end tell
end run
on mergeLayers()
tell application "Adobe Photoshop CS5.1"
tell thisDoc
try -- if there are none invisible it will throw an error
delete (every layer of layer set groupToTidy whose visible is false)
end try
try -- if there are none invisible it will throw an error
delete (every layer set of layer set groupToTidy whose visible is false)
end try
try -- there may be no groups within the group
set mergeGroups to (name of every layer set of layer set groupToTidy whose visible is true)
log mergeGroups
repeat with i from 1 to (count of mergeGroups)
set groupToMerge to item i of mergeGroups
log groupToMerge
merge layer set groupToMerge of layer set groupToTidy
end repeat
end try
set mergeLayers to (name of every art layer of layer set groupToTidy whose visible is true)
log mergeLayers
repeat with i from 1 to (count of mergeLayers) - 1
set layerToMerge to item i of mergeLayers
log layerToMerge
merge layer layerToMerge of layer set groupToTidy
end repeat
end tell
end tell
end mergeLayers
Model: 2 x 2.8 GHz Quad-Core Intel Xeon
AppleScript: 2.1.2
Browser: Firefox 3.6.14
Operating System: Mac OS X (10.6)
Browser: Safari 533.19.4
Operating System: Mac OS X (10.6)