Applescript to Javascript - InDesign CS3

I have an Applescript that I need to convert to a Javascript.

I have read some of the documentation for Javascript but I am finding it tough.

Can anyone show me the equivalent Javascript for this Applescript

set the thefolder to alias "macHD:Users:Smith:Desktop:PDFs:"
tell application "Adobe InDesign CS3"
    tell document 1
        set the ADSTACK to every text frame whose label starts with "Product"
        if (count of ADSTACK) = 1 then
            set the AdLabel to label of item 1 of ADSTACK
            set AdNumber to word 3 of AdLabel & ".pdf"
            tell item 1 of ADSTACK
                try
                    set thisAd to thefolder & AdNumber as text as alias
                    place thisAd
                on error
                    display dialog "Ad not found" buttons {"Cancel"} with icon 1
                end try
            end tell
        else
            repeat with i from 1 to count of ADSTACK
                set the AdLabel to label of item i of ADSTACK
                set AdNumber to word 3 of AdLabel & ".pdf"
                tell item i of ADSTACK
                    try
                        set thisAd to thefolder & AdNumber as text as alias
                         place thisAd
                    on error
                        display dialog AdNumber & " not found" buttons {"Cancel", "OK"} default button 2 with icon 1
                    end try
                end tell
            end repeat
        end if
    end tell
end tell

If this is a working Script then why the need for an ExtendScript version? Have you tried the Adobe Forums?

I did this applescript as a quick test.

Now the department involved want this process moved to a PC.

I have have tried the Adobe forums, but have not got a response as yet.

Well the reason would fair enough. The difference in the language is a Fair bit though. Things like the AppleScript’s ‘whose’ filtering (shorthand) just does not exist you need to create an Array, test for condition and push items to the Array. There is Nothing that I can see that can’t be done though.

Thanks,

I’ll have to find some time to dig around in the Javascript Guide for Indesign.

If anyone knows of other good references for learning Javascript, please let me know.

Hi,

I have this small book on my desk and can highly recommend it:

Scripting InDesign with JavaScript

Best regards,

Martin

P.S.: Yes, sometimes I need to automate PCs as well :lol:

There are NO PDF for versions CS3 & CS4 of InDesign.

Just download it. Thanks for the link.

Check your PM :wink: