help to create a script with a list of images and photoshop

here what i try to do:

i got a pretty long list of images
i need to open every 3images form the list and paste them into a three layer photoshop file: .psd which is created outside that folder

for example
img001.jpg+img002.jpg+img003.jpg===>img001.psd
img004.jpg+img005.jpg+img006.jpg===>img002.psd
etc

once the 3 file opened photoshop can handle the merging of the 3 files but i dnont know how to do open the images in a incremental way, the naming of the psd can be a problem too

thks for your time
jan

These routines could help you:

set largeAliasList to {"item 1", "item 2", "item 3", "item 4", "item 5", "item 6", "item 7", "item 8", "item 9"}

--> create lists of three items
set largeAliasList to subLists3Items(largeAliasList)

tell application "Adobe Photoshop 7.0"
	repeat with i from 1 to largeAliasList's length
		set threeImages to largeAliasList's item i
		--> if apps supports a list of alias: open threeImages
		open threeImages's item 1
		open threeImages's item 2
		open threeImages's item 3
		
		--> do whatever
		
		--> create a name for final file
		set PSDName to "whateverPSD" & i & ".psd" --> eg, "whateverPSD1.psd"
		
		--> do whatever
	end repeat
end tell

to subLists3Items(theList) --> theList's length = multiple of 3
	set newList to {}
	repeat with i from 1 to theList's length by 3
		set newList's end to {theList's item i, theList's item (i + 1), theList's item (i + 2)}
	end repeat
	return newList
end subLists3Items