So I tried adding using . No change. Still receive the error. Even if that had worked, the problem with using the preset is that you can’t save security settings in presets. So earlier in my code I set the Export Preferences and then try to export the file. However I commented out that section while testing the using . Thanks. Any other ideas would be appreicated.
“full name” returns an alias of file reference. When you concatenate that with a string (“.pdf”), you get a list. Try “set docName to full name as Unicode text”.
This sort of stuff is fairly obvious if you look at the log, BTW.
It may have been obvious to you but to those of us who are just starting to work with Applescript it isn’t that easy and basically that’s why we’re here… to learn what our mistakes are from people who know more than us. I hop this worked for sixlegsup also.
This sort of stuff is fairly obvious if you look at the log, BTW.
It may have been obvious to you but to those of us who are just starting to work with
Applescript it isn’t that easy and basically that’s why we’re here… to learn what our
mistakes are from people who know more than us.
Sometimes meaning is hard to interpret in message boards. As you spend more time here, you’ll see that Shane is a really nice/helpful guy. I think what he was getting at is that if you watch the events/responses in the log as your script runs, you’ll see when a variable is a list because it will be encosed in curly brackets. i.e. {} His comment seems intended as a tip, rather than to chastise.
It takes some time to get the hang of telling which line of code produced which log message, but it’s real handy once you get the hang of it.
Sorry for jumping to conclusions… it seemed out of place since I have been nothing short of amazed by all the help people are willing to provide on this site. Thanks for clarifying.
Yes, I’m really not a monster The OP was understandably frustrated – he’d written two long posts here and another elsewhere – and obviously wasted a lot of his time. My point was that you should always look at the log first; some things then become obvious, and can save you a lot of time (and frustration).
Thanks for your note Shane. The error verbage and event log didn’t sync in my mind, but it makes sense. This snippet seemed to work well (though I’ve refined it by stripping out the .indd suffix, etc)…
tell application "InDesign CS"
set myDoc to active document
set docName to full name of myDoc as Unicode text
export myDoc format PDF type to docName & ".pdf"
end tell
How is it better? It involves first making a list before coercing to text, which is less efficient, and you’re producing non-Unicode text, which means it could fail if some accented or foreign characters are used in the path. You were better off with the previous version.
I’m not sure why this is not better. First, it makes more sense to me to assign value and perform the coercion in the same statement, rather than spread that over the assignment and export statements. Second, it is my understanding that Finder performs an implicit coercion between strings and unicode text. I have created files and folders with unicode text, and using the string data type works every time. Finally, both pieces of code appear to perform the same tasks. The first performs a coercion then concatenates the text. The second concatenates a list then performs a coercion. As a whole code snippet I can’t determine how they effectually differ - they take the same time to perform the task. That’s just my take.
OK, so use: (set docName to full name of myDoc as Unicode text) & “.pdf”
No, although it works most of the time. It won’t work with many accented characters – you can’t convert them from Unicode to ASCII strings because there is no ASCII equivalent. For most Engilsh-speakers it’s not really a problem, but don’t expect it to behave on a non-English system.
Appearances can mislead…
Right.
No, it does a bit more than that. First it creates a list via the concatenation, and then to coerce to a string it has to first coerce the file reference separately to a string. Then you are coercing a list to a string, and the result of that depends on the value of AppleScript’s text item delimiters. So for safety’s sake it really needs to make sure they are set to the default. Otherwise you might get something unexpected:
set AppleScript's text item delimiters to {"something"}
-- whole lot of other stuff
tell application "InDesign CS"
set myDoc to active document
set docName to full name of myDoc & ".pdf" as string
end tell
By using the other method, you son’t have to worry about text item delimiters.
I was wondering if it was best to set the text item delimiters manually or just leave the default. That would be interesting to play with.
That does make sense that some unicode won’t translate, it’s just confusing to have to use a unicode data type when a ‘string’ seems most natural (for lack of a better word).
Thanks for the feedback. This little project has served as a good learning experience into the nuances and friggin frustrations of Applescript.
[quote=“iolaire”]
Here is a minor modification to Kari’s code that works for me as a droplet application. Make sure you change the text “My Printer Preset” to a printer preset name in InDesign CS. Save the script as an application and you should be able to drop a folder on it and all ID files will print. iolaire
Can this script be modified to print to a postscript file? I tried to modify it but it would not work using what I had…of course I am no scripter.
I would like to print to a PS file to a certain folder.
I have been using the Batch PDF export script for InDesign and I love it. now I’m trying to adapt that and the batch print from InDesign to a batch Illustrator. I think I have everything, except I need a way to select “OK” in the print dialog box. I have the user interaction set to never but it still pops up. Here is my script:
on open sourceFolders
with timeout of 100000 seconds
repeat with sourceFolder in sourceFolders
tell application “Finder”
try
– If you would like to include subfolders, you say - every file of entire contents of folder…
set idFiles to (every file of folder sourceFolder)
on error – work around bug if there is only one file
set idFiles to (every file of folder sourceFolder)
end try
end tell
if idFiles is not {} then
tell application "Adobe Illustrator 10.0.3"
set user interaction level to never interact
repeat with i from 1 to count of idFiles
open item i of idFiles
tell document 1
tell document 1
set myPreset to "Standard" -- name of print style to use
print using myPreset without print dialog
close without saving
end tell
end tell
end tell
end repeat
set user interaction level to interact with all
end tell
end if
return 10 -- try again in 10 seconds
end repeat
end timeout
You’re passing a list of Finder references to AI, which means the files are actually opened by the Finder, causing all sorts of potential problems with timing. Modify the relevant section thus:
try
– If you would like to include subfolders, you say - every file of entire contents of folder…
set idFiles to (every file of folder sourceFolder) as alias list
on error – work around bug if there is only one file
set idFiles to (every file of folder sourceFolder) as alias as list
end try