QuarkXPress - search picture by file name

I’d like to write a script for Quark 6.1 which makes easy search any picture by its name (or part of the name). But strange thing happen. I can’t coerce file path property of image to string to compare with target string. So I stop use this filter statement and rewrite code as a classic loop, but it’s much slower. Is there possibility to use coercion or compare in where, whose statements? Correct me, please!

tell application "QuarkXPress Passport"
	tell document 1
		set allPictures to every picture box whose ((file path of image 1) as text) contains "my favorite file.tif" 
	end tell
end tell

I also thought that it would be good idea to post all my code. It’s pretty slower but working. Waiting for you advises how to speed-up it! Thanks!

tell application "QuarkXPress Passport"
		display dialog "Enter picture number..." default answer "" buttons {"Cancel", "OK"} default button 2
	end try
	set gotolabel to text returned of result
	tell document 1
		set allBoxes to every picture box
		repeat with x from 1 to the count of allBoxes
			set thisBox to item x of allBoxes
			if file type of image 1 of thisBox is not null then
				set testvar to file path of image 1 of thisBox as string
				if testvar contains gotolabel then
					set targetpage to page number of page 1 of thisBox
					set current page to page targetpage
					set current box to thisBox
					display dialog "Done!" buttons {"OK"} default button 1 with icon 2
					exit repeat
				end if
			end if
		end repeat
	end tell
end tell

Hi There,


This past week or two I’ve created a script to do a find/replace of images in Quark.
Rather than coercing the filepath to a ‘string’ I coerced it to ‘text’.

set fn to (file path of image 1) as text

And then checked if it was what I was looking for like this:-

if fn is equal to "PATH_TO_FILE:replace_this_file_name.eps" then
	display dialog "found a file!"
end if

This worked for me, the only slight niggle I had was that once the script had replaced the pic I tried
applying a ‘scale’ and ‘offset’ but had one or two problems. In the end I looked for a box that had a
certain colour in it and put the picture in that. That worked ok. When I get chance I’ll go back and
solve the slight niggle.

Hope the code snippets help.



Nick, if your slight niggle was getting the off set of an image then here’s a snippet.

	set CurBox to object reference of current box
	copy (coerce ((offset of image 1 of CurBox) as measurements point) to list) to {Xoffset, Yoffset}
	set Xoffset to Xoffset as real
	set Yoffset to Yoffset as real
		set (offset of image 1 of CurBox) to {(Xoffset + 3), (Yoffset + 3)}	end try

Thanks for the reply Mark.
I was setting the offsets like this:-

set image 1 to "PATH_TO_FILE:" & newFileName as alias
set offset of image 1 of current box to {"-0,872 mm", "-0,872 mm"}
set scale of image 1 of current box to {"102", "102"}

The find/replace worked fine, it was just the setting of the scale and offsets that failed???

Cheers Nick

Thanks for your answer but my question was different. How to use “file path” in where or whose filters. It’s much faster than run a loop or check conditions…

Yeah, wasn’t sure about that bit :confused:

nick decimal points in you measures not commas.

i said that just looking at your post without checking tut tut appears both work.

tell application "QuarkXPress"
	set CurBox to object reference of current box
	set offset of image 1 of current box to {"-0,872 mm", "-0,872 mm"}
	set scale of image 1 of current box to {"102", "102"}
end tell

Hi Mark, thanks for the reply. I’ve got a script I can run through the script menu in Quark, that works fine with commas.
Think it might be to do with the fact the pic box isn’t selected.