Hi everyone,
first of all, nice to be a part of this community
It is as it is. I have a question concerning a applescript I wrote to access QuarkXpress-documents to process them in a batch with the find and replace function of QuarkXPress.
System: OS X 10.7.5
QuarkXPress: 8.5.1
Here is the applescript:
--choose directory containing quark files
tell application "Finder"
activate
set source_folder to choose folder with prompt "Select folder:"
set source_files to (files of entire contents of source_folder whose file type is "XPRJ")
set source_files to sort source_files by name
set source_files to (sort source_files by name) as alias list
end tell
--loop through quark documents
set findString to "\\?\\?\\?,\\?\\? ââÂŹ"
set replacestring to "000,00 ââÂŹ"
tell application "QuarkXPress"
activate
repeat with i from 1 to length of source_files
set quarkfile to item i of source_files
open quarkfile as alias use doc prefs yes remap fonts no without reflow
tell document 1
set (text of every story whose it is findString) to replacestring
end tell
save document 1
close document 1 saving no
end repeat
end tell
This applescript works as long as findstring is a plain text, but the findstring need to be â???,?? ââÂŹâ (Explanation: in Quark ? is a placeholder for 1 character (roughly like in a regex pattern!)).
I have to escape the backslash, because applescript uses the backslash itself as a escape character.
If I escape the backslash as you can see above in the applescript, I get the following result:
Applescript Error message box:
ĹžQuarkXPress" found an error:canât set Ĺževery text of every story of document 1 whose it = â\?\?\?,\?\? ââÂŹâ" to Ĺž"000,00 ââÂŹ"".
Results pane message:
error âĹžQuarkXPressâ found an error:canât set Ĺževery text of every story of document 1 whose it = "\\?\\?\\?,\\?\\? ââÂŹ"" to Ĺž"000,00 ââÂŹ"â.â number -10006 from every text of every story of document 1 whose it = â\?\?\?,\?\? ââÂŹâ
I tried everything to escape the backslash even with âASCII character (92)â but with the same result.
Does anybody know what I am doing wrong or how I can use the placeholder pattern in QuarkXpress 8.5.1 find and replace via applescript?
I appreciate any help anyone can give.
Thanks in advance.
Kind regards
helpit
Model: Mac Pro (Early 2009)
AppleScript: 2.2.1
Browser: Safari 537.36
Operating System: Mac OS X (10.7)