Copy link to clipboard
Copied
Hello all,
I was wondering if anyone knows how to run an applescript on multiple documents. Lets say I have ten INdd CS4 documents in a folder. I would like to open one , run my AS script, save and close, open next.... etc.
Maybe something like this already exists. any idea or suggestion would be very helpful.
thank you very much
Dawid
Copy link to clipboard
Copied
Hi Dawid,
Here is an example:
tell application "Finder"
set myInFolder to choose folder with prompt "Select a folder"
set myFilelist to files in myInFolder whose name ends with ".indd"
end tell
tell application "Adobe InDesign CS3"
set user interaction level of script preferences to never interact
repeat with myDoc from (count myFilelist) to 1 by -1
set myCurrentFile to item myDoc of myFilelist
open myCurrentFile
set myCurDocument to active document
tell myCurDocument
-- do your staff here
close saving yes -- save and close
end tell
end repeat
set user interaction level of script preferences to interact with all
beep 3
display alert "Finished!"
end tell
Hope this helps.
Kasyan
Copy link to clipboard
Copied
Hi you others in this tread!
First of all let me thank you for your postings. They`ve been to great help.
Still I`m not getting it "right" on my own.
I run this on a relatively new iMac with the Adobe Creative Suite CS5
Firstly let me show you my script so far:
---------------------------------------------------------
tell application "Finder"
set myInFolder to choose folder with prompt "Select a folder"
set myFilelist to files in myInFolder whose name ends with ".indd"
end tell
tell application "Adobe InDesign CS5"
set user interaction level of script preferences to never interact
repeat with myDoc from (count myFilelist) to 1 by -1
set myCurrentFile to item myDoc of myFilelist
open myCurrentFile
set myCurDocument to active document
tell myCurDocument
set Doc_Name to name
export format PDF type to "Macintosh HD:Users:smael:Desktop:out:" & Doc_Name & ".pdf" without showing options
close saving yes -- save and close
end tell
end repeat
set user interaction level of script preferences to interact with all
beep 3
display alert "Finished!"
end tell
---------------------------------------------------------
For some reason it doesn`t work 100%.
What I would like to do
Too much to ask for maybe?
I`m totally new to "programing" so all help is appreciated!
Regards
Terje
Copy link to clipboard
Copied
This did what you wanted with the briefest of tests…
set InputFolder to choose folder with prompt "Select an input folder"
tell application "Finder"
set IDFileList to every file of InputFolder whose name ends with ".indd"
set IDcount to count of IDFileList
end tell
log IDcount
if IDcount > 0 then
set OuputFolder to choose folder with prompt "Select an output folder"
tell application "Adobe InDesign CS5"
activate
set user interaction level of script preferences to never interact
repeat with i from 1 to IDcount
open (item i of IDFileList)
set DocRef to the active document
tell DocRef
set DocName to name
set DocName to text 1 thru -6 of DocName
log DocName
set SaveName to DocName & ".trykk.pdf"
set SavePath to (OuputFolder as text) & SaveName
export format PDF type to SavePath ¬
using "[Smallest File Size]" without showing options
close saving yes
end tell
end repeat
set user interaction level of script preferences to interact with all
beep 3
display alert "Finished!" giving up after 3
end tell
else
display dialog "Nothing to process?" giving up after 3
end if
Copy link to clipboard
Copied
Wow!!
;o)
That made my day!
The only "bug" is that it still only processes one inDesign file, even when the folder contains several inDesign files.
And there`s no alerts as well (finished), from what I could tell from the script, that it should be.
Any idea?
Regards Terje
Copy link to clipboard
Copied
I think that's the first time I've tried use AppleScript with CS5. A couple of things I noticed. I could not reduce the text of the name until I'd first set it to a variable can't see why should just be a string… When I first ran on a bunch of files including older CS2 ones it stopped at the second claiming that the 'user had canceled' which I ain't touched nothing… Tested with just new CS5 files and no problems… I have not had the time to check but there may be some opening options required for use with older files… In one or two places I did include 'log' so you can see the values of variables displayed in the event log… you can remove these they are not needed… What is the last report in your event log…?
Copy link to clipboard
Copied
Hi!
I tested it on a second iMac and it worked wonderfully!
I guess I have some sort of bug in my machine or during installation of CS5.
I have a few other ideas with that script, so I`m eager to begin ;o)
Thanks again!
Terje
Copy link to clipboard
Copied
If you found this thread via a web/forum search and are new to scripting… Then consider your choice of language… On your OS you can go with AppleScript or use Adobe's ESTK (javascript based) language. There are pros and cons to each. You will certainly get more help in this forum with the latter. Either way have fun… Glad you got it working anyhow…
Copy link to clipboard
Copied
With applescript, you can write one script and save it as an app - then drag and drop all your files at once onto the script and let them fly. Or you can open the script and have it prompt you for the file name as each one completes. I'm not too familiar with JS though - perhaps the same can be done.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now