Avatar billede landmark Nybegynder
29. marts 2006 - 21:00 Der er 1 kommentar og
1 løsning

applescript til javascript

hej er der nogen som er i stand til at oversætte dette apple script til javascript ??

- eller endnu bedre... - findes der et oversættelsesprogram til dette ??

sådan ser apple scriptet ud:


global foundPaths, foundPathNames
set foundPathNames to {}
set foundPaths to {}
set missedLinks to "" -- name of links not found
tell application "Adobe InDesign CS2"
    activate
    -- choose pic folder
    set folderpath to (choose folder with prompt "Choose folder containing pictures:") as Unicode text
    tell document 1
        set missingLinks to every link whose status is link missing
        if missingLinks is not {} then
            set missingLinkNames to name of every link whose status is link missing
            set linkcount to count of items of missingLinkNames
            -- search for file recursively
            my checkforfile(folderpath, missingLinkNames, linkcount)
            set foundCount to count of items of foundPathNames
            -- see if file was found, and relink if so
            repeat with i from 1 to linkcount
                repeat with j from 1 to foundCount
                    if contents of item j of foundPathNames = contents of item i of missingLinkNames then
                        relink item i of missingLinks to alias (item j of foundPaths)
                        exit repeat
                    else if j = foundCount then
                        set missedLinks to missedLinks & (item i of missingLinkNames) & ", "
                    end if
                end repeat
            end repeat
            try -- in case there aren't any
                update (every link whose status is link out of date)
            end try
            if missedLinks = "" then
                display dialog "All links updated."
            else
                display dialog "The following links weren't found: " & return & (text 1 thru -3 of missedLinks)
            end if
        else
            display dialog "No links missing."
        end if
    end tell
end tell

on checkforfile(folderpath, fileNames, n)
    set theList to list folder file folderpath without invisibles
    repeat with anItem in theList
        set thePath to alias (folderpath & anItem) as Unicode text
        if thePath ends with ":" then
            set searchResult to my checkforfile(thePath, fileNames, n)
            if searchResult is false then
                return false
            end if
        else if contents of anItem is in fileNames then
            set end of foundPathNames to contents of anItem
            set end of foundPaths to thePath
            if (count of items of foundPaths) = n then
                return false
            end if
        end if
    end repeat
    return true
end checkforfile
Avatar billede thesurfer Nybegynder
29. marts 2006 - 22:17 #1
Så vidt jeg kan se, arbejder applescriptet med filer. Det kan JavaScript ikke.
Der skal du over i et serverside scriptsprog, som f.eks. ASP eller PHP.

/theSurfer
Avatar billede landmark Nybegynder
02. april 2006 - 13:47 #2
Jeg søgte i USA og fandt svaret: det er ikke noget problem at programmere dette i javascript.

fandt i en søgning, David Saunders, en ældre herre på 63 år. Men han ved tydeligvis hvad han taler om.
http://www.pdsassoc.com/index.php?Nav=javas&Ban=JavaScript+and+InDesign+CS&Info=javascripts.html
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester