quark: search & replace problem

Hi all, the situation is:

i have 1500+ quark documents which are located in a Folder_1, this folder has about 4 subfolders, some subfolder has quarkdocs, some not. Every quarkdoc(mostly 1 page) has several textboxes. 1 or more textboxes contain a certain textphrase, “boat” for example. This phrase has to be replaced by “ship”. So in all the 1500+ quarkdocs the word “boat” has to be replaced by “ship”. I found a script by jonn8, that can do a search/replace sort of thing in quark, but this script only works when the text to be searched in is selected. This is how the script looks now, 1 quarkdoc at a time:


copy {"boat", "ship"} to {old_word, new_word}
set search_strings to {(old_word)}
set replace_strings to {(new_word)}

tell application "QuarkXPress_4.11"
	activate
	tell document 1
		set myselection to a reference to text of selection
		repeat with i from 1 to (count of search_strings)
			try
				set mysearch to (a reference to (text of myselection whose contents of it = (old_word)))
				set contents of mysearch to (new_word)
			end try
		end repeat
		display dialog "End"
	end tell
end tell

As you will understand this script doesn’t solve my problem, because i still have to manually select the text. Is there a way to select all the text that’s in a quarkdoc by script? Or other hints to make it possible to batch find/replace 1500+ quarkdocs?

Grtz, Bart 8)

ps. using Mac OS 9.2, Quark 4.11
ps2. i have PreFab player. So i can imitate a find & replace action in quark. But this only works when EVERY doc contains the phrase"boat", if not the script stops…so that’s why i want to try it by Applescript without the help of PreFab Player

change this line:

set myselection to a reference to text of selection

into

set myselection to a reference to text of every story

Seems to work with Quark 6.5.
:wink:

thnx Kjeld, you’re always a great help! :lol:

i have the complete script working now. Batch search and replacing in Quark 4.11(and so it seems in quark 6.5) ! The script:

  1. asks in which folder to look for quark documents, subfolders are also taken care of
  2. replaces a given phrase with a given phrase, the phrases are hard-coded, so NO dialog
  3. it saves the file

copy {"boat", "ship"} to {old_word, new_word}
set search_strings to {(old_word)}
set replace_strings to {(new_word)}

tell application "Finder"
	activate
	set source_folder to choose folder with prompt "Select the source folder:"
	set source_files to (files of entire contents of source_folder whose file type is "XDOC")
	set source_files to sort source_files by name
	try
		set source_files to (sort source_files by name) as alias list
	on error
		set source_files to (sort source_files by name) as alias as list
	end try
end tell

tell application "QuarkXPress_4.11"
	activate
	repeat with i from 1 to length of source_files
		set t_file to item i of source_files
		open t_file as alias use doc prefs yes remap fonts no without reflow
		tell document 1
			set myselection to (a reference to text of every story)
			repeat with i from 1 to (count of search_strings)
				try
					set mysearch to (a reference to (text of myselection whose contents of it = (old_word)))
					set contents of mysearch to (new_word)
				end try
			end repeat
		end tell
		close document 1 saving yes
	end repeat
	set the listLength to the count of source_files
	display dialog "Klaar! Er zijn " & listLength & " quarkdocumenten aangepast." buttons {"OK"} default button "OK"
end tell

Grtz, Bart 8)

This script actually does what I need to do, minus one thing:

I need to find a word in a certain font, and change the word to the same word in a different font. How can I add this to this script?

Any help is appreciated! Thanks!