RE: Newbie Quark Scripting critique
RE: Newbie Quark Scripting critique
- Subject: RE: Newbie Quark Scripting critique
- From: "Wallace, William" <email@hidden>
- Date: Wed, 23 Oct 2002 12:31:15 -0500
Okay, this also works (thanks for the input Brian):
tell application "QuarkXPress(tm) 4.11"
launch
set theFile to choose file with prompt "pick a file... any file."
set thePath to theFile as string
set oldTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to ":"
set penultimate to (count every text item of thePath) - 1
set pathToFile to ""
repeat with i from 1 to penultimate
set pathToFile to pathToFile & text item i of thePath & ":"
end repeat
set AppleScript's text item delimiters to oldTIDs
tell application "Finder"
if (folder "EPSfiles" of (pathToFile as alias) exists) is not true
then
make new folder with properties {name:"EPSfiles"} at
pathToFile as alias
end if
end tell
open theFile use doc prefs yes remap fonts no
set pageCount to count of pages of document 1
set docName to name of document 1
set outFolder to pathToFile & "EPSfiles:"
repeat with i from 1 to pageCount
set outFile to outFolder & docName & i & ".eps"
try
save page i of document 1 in outFile
end try
end repeat
close document 1 saving no
display dialog "My work is done here." & return & "I have generated " &
pageCount & " EPS files for you." & return & "Have a nice day."
end tell
I decided to have the user select a file to process from an Open dialog
box, thus pretty much guaranteeing that there is only one file being
processed and that the file being processed is the one the user intended (if
they can't select a file from a standard Open dialog box, then I can't help
them, right?). I still have to do the error checking on the filename length
and then handle that, but this is where I'm at so far.
My first question is: Is there an easier, more elegant way to get the path
to the chosen file (excluding the actual filename)? The way I went about it
here works fine, I guess, but it seems kind of Rube Goldberg-y to me. Have I
missed the obvious?
Second question: I seem to recall there being a debate about nesting Tell
blocks like I have them. Was any consensus reached? Is this bad form? Am I
playing with fire here?
Anybody got any insights? Hints? Tips? Words of praise? Derisive sneers?
Anything?
Thanks,
-Bill
PS Does anybody else find it really annoying that Quark feels the need to
launch itself when you open its dictionary in Script Editor, or if you
compile a script that references the Quark XPress application? Is it just
me?
William Wallace
Electronics Manager
McGraw-Hill/Contemporary
email@hidden
>
>On Tuesday, October 22, 2002, at 03:59 PM, Wallace, William wrote:
>
>> tell application "QuarkXPress(tm) 4.11"
>> set pageCount to count of pages of document 1
>> repeat with i from 1 to pageCount
>> set docName to name of document 1
>> set outFile to "Startup:Desktop Folder:" & docName &
i & ".eps"
>> save page i of document 1 in outFile
>> end repeat
>> end tell
>
>A few things leap to mind:
>1) set docName outside of your repeat loop. Since you're not
changing
>the document, it will stay the same throughout the life of the
repeat
>loop.
>
>2) Put in a try block around the save page statement. If something
>fails, you might want to stop and error, or you might want to try
to
>work around it, depending on what the problem is.
>
>3) Do you want to replace the documents always? I have a script
set up
>to check the ending folder and see if the document exists. If it
>doesn't, then it makes the file (this is for final builds of the
>publications). Obviously, this depends on your workflow, so you
will
>have to make the decision for yourself on that.
>
>=Brian
>
>--__--__--
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.