Pages zu Word mit Unterordnerstruktur?

chris90

Welscher Taubenapfel
Registriert
10.08.08
Beiträge
772
ich habe viele Pages Dateien, die in vielen Unterordnern liegen. Diese Dateien würde ich gerne per AppleScript als Word konvertieren. Das habe ich auch mal hinbekommen, aber nur, wenn ich alle Dateien in einen einzelnen Ordner kopiert habe. Jetzt würde ich gerne die Ordnerstruktur aufrechterhalten, so dass einfach die Word Datei zusätzlich zur Pages Datei in jedem Unterordner liegt. Hat da jemand einen Tipp für mich?
 

sedna

Galloway Pepping
Registriert
22.10.08
Beiträge
1.358
Hallo,

und ja mein Tipp:
Poste dein Skript, dann kann man dir die nötigen Änderungen nennen!

Gruß
 

chris90

Welscher Taubenapfel
Registriert
10.08.08
Beiträge
772
habe es hinbekommen. Das ist ein zusammenkopiertes Script, das sicherlich nicht der eleganteste Weg ist, aber funktioniert ;)
Code:
set my_pagesFolder to choose folder
tell application "Finder"
    set these_files to (every file of entire contents of my_pagesFolder whose kind is "Pages-Dokument") as alias list
end tell

repeat with i from 1 to the count of these_files
    set this_file to (item i of these_files)
  
    set test to this_file as text
    set theCharacters to characters of test
    set theReversedCharacters to reverse of theCharacters
    set theReversedFileName to theReversedCharacters as string
    set theOffset to offset of ":" in theReversedFileName
    set theReversedPrefix to text (theOffset + 1) thru -1 of theReversedFileName
    set thePrefix to (reverse of (characters of theReversedPrefix)) as string
  
    tell application "Pages"
        activate
        set the_document to open this_file
        set nn to the_document's name
        tell nn
            text 1 thru -7 as «class utf8»
        end tell
        set name_no_ext to the result
        -- doc oder docx:
        export the_document to file (thePrefix & ":" & name_no_ext & ".docx") as Microsoft Word
        close the_document
    end tell
end repeat
 

Pill

Adams Parmäne
Registriert
07.07.12
Beiträge
1.310
Hallo, hier mal der Versuch eines eleganteren Wegs:

Code:
set my_pagesFolder to choose folder
tell application "Finder"
    set these_files to (every file of entire contents of my_pagesFolder whose kind is "Pages-Dokument") as alias list
end tell

repeat with this_file in these_files
   
    tell application "Finder" to set thePrefix to container of this_file as text
   
    tell application "Pages"
        activate
        set the_document to open this_file
        set name_no_ext to text 1 thru -7 of (get name of the_document) as «class utf8»
        -- doc oder docx:
        export the_document to file (thePrefix & name_no_ext & ".docx") as Microsoft Word
        close the_document
    end tell
   
end repeat

Mangels Pages kann ich das Skript leider nicht testen, es sollte aber so funktionieren.
 

chris90

Welscher Taubenapfel
Registriert
10.08.08
Beiträge
772
danke :) ich habe es dann selbst noch etwas eleganter hingekommen - wenn auch nicht so elegant wie dein Script ;)
Wichtig war noch per Try ein do shell script mit killall Pages einzubauen, weil Pages immer mal wieder Probleme hatte eine Datei zu schließen. So hat es dann geklappt ca. 500 Pages und Keynote Dateien in Word/PPT und PDF umzuwandeln.