folders within folders for catalog script

I am trying to put together a script that will build a catalog of images in Quark 6.5 based on a predefined template on my machine, but I am having trouble with gettign the script to look beyond the original folder that I choose, ie. it only catalogs the images on the first level of the folder structure-I need it to also include any images within subfolders on the main folder

Here’s the script that I’ve been able to hack together… any help would be appreciated

tell application “QuarkXPress”
activate

tell document 1
	set thefolder to choose folder with prompt "Choose folder containing images to catalog:"
	try
		tell application "Finder"
			set theImageList to every file of thefolder whose kind is not "alias" and ¬
				file type is "TIFF" or file type is "EPSF" or file type is "PICT" or ¬
				file type is "JPEG" or file type is "GIFf" or file type is "BMP " or ¬
				file type is "RIFF" or file type is "BINA" or file type is "PNTG" or ¬
				file type is "BMPf" or file type is "EPSP"
			
			if class of theImageList is not list then set theImageList to theImageList as list
			set theImageNameList to the name of every file of thefolder whose kind is not "alias" and ¬
				file type is "TIFF" or file type is "EPSF" or file type is "PICT" or ¬
				file type is "JPEG" or file type is "GIFf" or file type is "BMP " or ¬
				file type is "RIFF" or file type is "BINA" or file type is "PNTG" or ¬
				file type is "BMPf" or file type is "EPSP"
			
			if class of theImageNameList is not list then set theImageNameList to theImageNameList as list
		end tell
	on error
		beep
		display dialog "No images were found in this folder." buttons {"Cancel"} default button 1
	end try
	
	
	set theNumberOfImages to the number of items of theImageList
	
	set theCounter to 1
	set theMasterPage to master spread of current page
	repeat
		tell current spread
			set thePictureBoxList to the object reference of every picture box
			set theNumberOfPBoxes to number of items of thePictureBoxList
			set theTextBoxList to the object reference of every text box
			repeat with i from 1 to theNumberOfPBoxes
				set image 1 of (item i of thePictureBoxList) to (item theCounter of theImageList) as alias
				set bounds of image 1 of (item i of thePictureBoxList) to proportional fit
				set story 1 of (item i of theTextBoxList) to (item theCounter of theImageNameList)
				set theCounter to theCounter + 1
				if theCounter > theNumberOfImages then
					beep 2
					return
				end if
			end repeat
		end tell
		set theNewSpread to make new spread at end
		show theNewSpread
		set master spread of current page to theMasterPage
	end repeat
end tell

end tell

Hi,

The ‘return’ in these statements:

if theCounter > theNumberOfImages then
beep 2
return
end if

will return from the run handler (the script will quit). So the outer repeat just runs until the ‘return’. Instead of ‘return’ use ‘exit repeat’.

The other main thing is that when you get the list with:

set theImageList to every file of thefolder whose kind is not “alias” and …

this only gets a list of files from theFolder and not all subfolders of thefolder. There are several ways to search the subfolders for your files. I don’t have Quark so don’t know exactly what you’re doing, but think that you would want to think about how you want the layout as you get the files from the subfolders.

gl,

I think you’re looking for “entire contents”. Eg:

tell application "Finder"
	set {theImageList, theImageNameList} to {it, name} of (files of entire contents of theFolder whose file type is in {"TIFF", "JPEG"}) --> or whatever filter reference
end tell