Hi,
I want to create postscript files from a document opened in QuarkXpress. I’ve searched bbs and found the script that does that. I’ve modified it a little bit to suit my needs. However, I cannot overcome one obstacle which is naming of PS files that are created. The script creates following names for ps files:
-
If there is less than 10 pages in a document ps files are named: 1_of_9_Document1.ps, 2_of_9_Document1.ps, 3_of_9_Document1.ps etc.
-
If there is more than 10 but less than 99 pages in a document ps files are named:
01_of_15_Document1.ps, 02_of_15_Document1.ps, 03_of_15_Document1.ps, …, 010_of_15_Document1.ps, 011_of_15_Document1.ps, etc. -
If there is more than 100 but less than 999 pages in a document ps files are named:
001_of_200_Document1.ps, 002_of_200_Document1.ps, 003_of_200_Document1.ps, …, 0010_of_200_Document1.ps, 0011_of_200_Document1.ps,… 0100_of_200_Document1.ps, 0101_of_200_Document1.ps, 0102_of_200_Document1.ps, etc.
I what the files to be named in this style:
- If there is more than 10 but less than 99 pages in a document ps files are named:
01_of_15_Document1.ps, 02_of_15_Document1.ps, 03_of_15_Document1.ps, …, 10_of_15_Document1.ps, 11_of_15_Document1.ps, etc.
I want to insert zeros before pages from 1 to 9. I don’t want to insert 0 before 10, 11, 12 etc.
- If there is more than 100 but less than 999 pages in a document ps files are named:
001_of_200_Document1.ps, 002_of_200_Document1.ps, 003_of_200_Document1.ps, …, 010_of_200_Document1.ps, 011_of_200_Document1.ps,… 100_of_200_Document1.ps, 101_of_200_Document1.ps, 102_of_200_Document1.ps, etc.
I want to insert two zeros before pages from 1 to 9, one zero for pages 10 to 99. I don’t want to insert 0 before 100, 101, 102 etc.
The script is listed below.
with timeout of 6000 seconds
try
set FileName to name of front document of application "QuarkXPress PassportD"
set thePath to (choose folder with prompt "Choose folder to save PS files:") as text
tell application "QuarkXPress"
activate
tell document 1
tell print setup
set data format to binary data
set resolution to 300
set page position to left position
end tell
set PageCount to count pages
set PageName to name of page 1
repeat with i from 1 to PageCount
set PageName to name of page i
set i to PageName
if PageCount < 10 then
print (page i) PostScript file thePath & i & "_" & "of_" & PageCount & "_" & FileName & ".ps"
else
if PageCount >= 10 and PageCount <= 99 then
print (page i) PostScript file thePath & "0" & i & "_" & "of_" & PageCount & "_" & FileName & ".ps"
else
if PageCount >= 100 and PageCount <= 999 then
print (page i) PostScript file thePath & "00" & i & "_" & "of_" & PageCount & "_" & FileName & ".ps"
end if
end if
end if
end repeat
display dialog "Finished!" with icon note
end tell
end tell
on error the error_message number the error_number
set the error_text to "ERROR: " & the error_number
display dialog the error_text with icon 0 buttons {"OK"} default button 1
return the error_text
end try
end timeout
I’ve searched bbs and the web but didn’t find the solution to my problem.
Thanks in advance for any help!
-Paff