Mac Sierra - Batch Convert Pages to Plain Text
This script works for me, tested on MacOS Sierra and Pages Version 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