Mac Sierra - Conversione batch di pagine in testo normale

4

Cercando di convertire in batch le pagine in testo normale, ma continuo a riscontrare problemi con i permessi dei file. (Uso di Sierra 10.2.3 dopo l'aggiornamento da 10.2.2)

filename could not be exported. You don't have permission.

Due metodi finora:

on run
    tell application "Finder"
        set mfolder to "Macintosh HD:Users:me:Documents:convertme:"
        set theFiles to name of every file of folder mfolder
    end tell
    set theFolder to "Macintosh HD:Users:me:Documents:converted:"
    tell application "Pages"
        activate
        repeat with aFile in theFiles
            open aFile
            set sourceFolder to POSIX path of aFile
            set newsourceFolder to characters 1 thru -8 of sourceFolder as string
            set theFolder to newsourceFolder & ".txt"
            export front document to POSIX file theFolder as unformatted text
            close front document
        end repeat
    end tell
end run

Ho provato anche con Automator: in Ask for Finder Item

function run(input, parameters) {
    inFile  = Path( input );
    outFile = Path( input.toString().replace(/\.[^\.]+$/, '.pdf') );
    pages    = Application('Pages');
    document = pages.open( inFile );
    pages.export(document, {to: outFile, as: 'PDF'});
    pages.close(document, {saving: 'no'});
    return outFile;
}

Autorizzazioni sulla cartella impostata su: tutti leggono e scrivono

    
posta ina 06.02.2017 - 15:16
fonte

1 risposta

2

Questo script funziona per me, testato su MacOS Sierra e Pagine Versione 6.0.5

set mfolder to "Macintosh HD:Users:me:Documents:convertme:"
set destFolder to "Macintosh HD:Users:me:Documents:converted:"

tell application "Finder" to set theNames to name of files of folder mfolder

tell application "Pages"
    repeat with aName in theNames
        set theDoc to open ((mfolder & aName) as alias)
        set newFile to destFolder & (text 1 thru -7 of aName) & ".txt" -- concat destFolder and the name without the ".pages" extension 
        my makenewFile(newFile)

        export theDoc to file newFile as unformatted text
        close theDoc
    end repeat
end tell

on makenewFile(thePath)
    close access (open for access thePath)
    -- delay 0.5 -- use the delay command, If you still have a permission issue,  increase the number of seconds
end makenewFile
    
risposta data 08.02.2017 - 05:09
fonte

Leggi altre domande sui tag