Make Image Catalog in QuarkXpress

Hello all,

I am extremely new to AppleScript. I was given an ApplesSript by a buddy of mine back when I was doing prepress and side jobs of production. What it did was made a Image Catalog from a folder of images in QuarkXpress. Now that I’m needing to do this on a regular basis, I looked for an AppleScript that did just that. I tried the old script and it didn’t in Quark 6 and Mac OSX 10.3.2. Anyone know of a script that will do this?

Thanks!

We can help. Open that script in the script editor and paste it into a message here. We can help you make it work in Q6. (If the script was given to you only as a compiled application, you won’t be able to do this “ you’ll have to get a hold of your friend and ask for the source code.)

If you’re willing to ditch that script, you can find two similar offerings on this site. Go to http://scriptbuilders.net/ and do a search for “image catalog.” You’ll get two good alternatives.

You might also want to check out this: http://www.creativepro.com/software/home/1896.html

Thank you for any help you can give, in the mean time I will check out those other links, but would love to keep this one.

set myLocation to my folderPathOf(path to me)
set theDemoFile to myLocation & "Image Catalog Template"

tell application "QuarkXPress"
	activate
	
	try
		set theOpenDOcs to name of every document
	on error
		set theOpenDOcs to {}
	end try
	try
		if "Image Catalog Template" is not in theOpenDOcs then
			open file theDemoFile use doc prefs (constant KPRFyes (remap fonts no do auto picture import (constant KPRFyes))
		end if
	on error
		repeat
			set theChosenDoc to choose file of type "XTMP" with prompt "Where is Image Catalog Template?"
			set theNameOfTheChosenDoc to my nameOf(theChosenDoc)
			if theNameOfTheChosenDoc is "Image Catalog Template" then
				open theChosenDoc use doc prefs (constant KPRFyes (remap fonts no do auto picture import (constant KPRFyes))
				exit repeat
			end if
		end repeat
	end try
	
	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
					the (class fitp) is "TIF" or the (class fitp) is "EPS" or
					the (class fitp) is "PICT" or the (class fitp) is "JPG"
				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
					the (class fitp) ?is "TIF" or the (class fitp) is "EPS" or 
					the (class fitp) ?is "PICT" or the (class fitp) is "JPG"
				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

on folderPathOf(filePath)
	set reversedFilePath to (reverse of characters of (filePath as text) as text)
	set theOffset to (length of reversedFilePath) - (offset of ":" in reversedFilePath)
	return (characters 1 thru theOffset of (filePath as text)) & ":" as text
end folderPathOf

on nameOf(aFile)
	set aBackwardsFilePath to (reverse of characters of (aFile as text) as text)
	set theOffset to (offset of ":" in aBackwardsFilePath)
	set theOffset to (length of aBackwardsFilePath) - theOffset + 2
	return (characters theOffset thru -1 of (aFile as text)) as text
end nameOf

Update: Just tried the creativepro.com link, and it works, but the link to the file is no longer valid.

We’re getting there.

This script works for me on a folder of JPEG’s, except that I had to change the “JPG” file type filter in your script to “JPEG” – file types are usually 4 chars.

What exactly do you mean when you say, “Well, I tried the old AS and it attempted to work in Quark 6 and Mac OSX 10.3.2.” ?

Are you using the same base template document you were using when this was working previously?

Does it give you any error or message at all?

If you open the script in the script editor and then click “Event Log” at the bottom of the window, and then press the run button, do you see anything happening?

Have you tried it with Quark 4 or 5 under OSX?

Well, when I try and run the AppleScript, it does attempt to work. It opens the template (same exact one as before) and asks me to locate a folder of images to work with. It does not matter what foler of what type(s) of images I want to place into this. It tells me that “No images were found in this folder.” at which point the only option I have is to cancel out of that action. I really, really do appreciate your guys willingness to help me on this.

P.S. I no longer have access to version 4 or 5 of Quark under OSX.

You made the changes to the file type filters? What types of files are in the art folder? If you open the script in script editor and click the events button at the bottom, you’ll see how far your script is getting. I’m guessing it’s not finding any files of the types for which it’s looking. You can post that and the latest version of your script here and we’ll go to round 2.

Well, I think I am changing the file type filters…both in the script and then on the actual files themselves. I have tried every combination I can think of (keep in mind I am a definate NEWB to this.) Is it entirely possible for you to copy-paste what you are using so I can see what it is you did differently? Gosh I feel silly…thanks again!
As far as the types of art I have tried to use this with are .tif, .eps and .jpg files. I don’t have any pict files to try out, otherwise I would.

:cry: :lol: :?

Here is the latest version of the script:

set myLocation to my folderPathOf(path to me)
set theDemoFile to myLocation & “Image Catalog Template”

tell application “QuarkXPress”
activate

try
	set theOpenDOcs to name of every document
on error
	set theOpenDOcs to {}
end try
try
	if "Image Catalog Template" is not in theOpenDOcs then
		open file theDemoFile use doc prefs «constant KPRFyes » remap fonts no do auto picture import «constant KPRFyes »
	end if
on error
	repeat
		set theChosenDoc to choose file of type "XTMP" with prompt "Where is “Image Catalog Template”?"
		set theNameOfTheChosenDoc to my nameOf(theChosenDoc)
		if theNameOfTheChosenDoc is "Image Catalog Template" then
			open theChosenDoc use doc prefs «constant KPRFyes » remap fonts no do auto picture import «constant KPRFyes »
			exit repeat
		end if
	end repeat
end try

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 ¬
				the «class fitp» is "TIFF" or the «class fitp» is "EPS" or ¬
				the «class fitp» is "PICT" or the «class fitp» is "JPEG"
			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 ¬
				the «class fitp» is "TIFF" or the «class fitp» is "EPS" or ¬
				the «class fitp» is "PICT" or the «class fitp» is "JPEG"
			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

on folderPathOf(filePath)
set reversedFilePath to (reverse of characters of (filePath as text) as text)
set theOffset to (length of reversedFilePath) - (offset of “:” in reversedFilePath)
return (characters 1 thru theOffset of (filePath as text)) & “:” as text
end folderPathOf

on nameOf(aFile)
set aBackwardsFilePath to (reverse of characters of (aFile as text) as text)
set theOffset to (offset of “:” in aBackwardsFilePath)
set theOffset to (length of aBackwardsFilePath) - theOffset + 2
return (characters theOffset thru -1 of (aFile as text)) as text
end nameOf

This is what I would use (though a shell command is probably faster to find the images):

property file_types : {"TIFF", "EPSf", "PICT", "JPEG"} --adjust as necessary
property file_extensions : {"tif", "tiff", "eps", "pict", "picture", "jpg", "jpeg"} --adjust as necessary
property temp_name : "Image Catalog Template"

set the_folder to (choose folder with prompt "Choose folder containing images to catalog:") as string
set the_images to get_folder_list(the_folder, file_types, file_extensions, true, false)
if the_images = {} then
	beep
	display dialog "No valid images found in chosen folder." buttons {"OK"} default button 1 with icon 0 giving up after 10
	return
end if
set image_count to (count the_images)

tell application "Finder" to set parent_path to container of (path to me) as string
set the_temp_file to parent_path & temp_name

tell application "QuarkXPress"
	activate
	try
		set open_documents to name of documents
	on error
		set open_documents to {}
	end try
	try
		if temp_name is not in open_documents then open file the_temp_file use doc prefs yes remap fonts no do auto picture import yes
	on error
		repeat
			set chosen_file to choose file of type "XTMP" with prompt "Where is ?" & temp_name & "??"
			if (my get_name(chosen_file)) = temp_name then
				open chosen_file use doc prefs yes remap fonts no do auto picture import yes
				exit repeat
			end if
		end repeat
	end try
	
	tell document 1
		set the_counter to 1
		set the_master_page to master spread of current page
		repeat
			tell current spread
				set picture_box_refs to object reference of picture boxes
				set text_box_refs to object reference of text boxes
				set count_text_box_refs to (count of picture_box_refs)
				repeat with i from 1 to count_text_box_refs
					set the_image to item the_counter of the_images
					tell (item i of picture_box_refs)
						set image 1 to the_image as alias
						set bounds of image 1 to proportional fit
					end tell
					set story 1 of (item i of text_box_refs) to (my get_name(the_image))
					set the_counter to the_counter + 1
					if the_counter > image_count then
						beep 2
						return
					end if
				end repeat
			end tell
			set new_spread to make new spread at end
			show new_spread
			set master spread of current page to the_master_page
		end repeat
	end tell
end tell

on get_folder_list(the_folder, file_types, file_extensions, with_subfolders, inc_folders)
	set the_files to {}
	tell application "Finder" to set folder_list to every item of folder the_folder
	repeat with new_file in folder_list
		try
			set temp_file_type to file type of new_file
			set temp_file_extension to name extension of new_file
		on error
			set temp_file_type to "folder"
			set temp_file_extension to ""
		end try
		if file_types contains temp_file_type or file_extensions contains temp_file_extension then set end of the_files to (new_file as string)
		if temp_file_type = "folder" then
			if inc_folders = true then set end of the_files to (new_file as string)
			if with_subfolders = true then set the_files to the_files & my get_folder_list((new_file as string), file_types, file_extensions, with_subfolders, inc_folders)
		end if
	end repeat
	return the_files
end get_folder_list

on get_name(the_path)
	set old_delim to AppleScript's text item delimiters
	set AppleScript's text item delimiters to {":"}
	set the_name to (text item -1 of (the_path as string))
	set AppleScript's text item delimiters to old_delim
	return the_name
end get_name

Jon

That works great! Now I will try to decipher what I was doing wrong. I appreciate it very much! Thank you!

Looks like John has sorted your problem; However, for others that might come across this link.

The above code posted by tommy is in fact the very same as what you’ll find in ScriptBuilders under Image Catalog 1.0 by the legendary Sal Soghoian. I guess it wasn’t written with Q6 and OS 10.3 in mind.

P.S.: John. won’t be long till your known as. legendary!