Tengo el siguiente applescript como único componente de una aplicación Automator:
on run {input, parameters}
repeat with theFile in input
tell application "Pages"
set theDoc to open theFile
set theDocName to name of theDoc
-- I implemented the sanitization of spaces to underscores in hope of fixing this present issue but it has not helped.
set sanitizedDocName to do shell script "echo " & quoted form of theDocName & " | sed -e 's/ /_/g'"
set theName to sanitizedDocName & "-auto-text"
display dialog (":Users:slu:automator-text-export:" & theName & ".txt")
export front document to file (":Users:slu:automator-text-export:" & theName & ".txt") as unformatted text
close theDoc saving no
end tell
end repeat
return input
end run
Creo que la intención se explica por sí misma. Puedo utilizar los fragmentos que ya he encontrado en línea para pedir finder para la ruta del archivo de entrada fue de, por ejemplo:
tell application "Finder"
-- Actually theFilesFolder is unused here
set theFilesFolder to (folder of theFile) as text
end tell
Este fragmento funciona para exportar correctamente a un lugar relativo a las posiciones originales de los archivos.
Pero específicamente quiero hacer que todas mis exportaciones vayan a un directorio predeterminado, pero no sé dónde puedo encontrar documentación sobre cómo construir una representación AppleScript adecuada de una ubicación del sistema de archivos. También he intentado montar la ruta con sólo barras en lugar de dos puntos, pero hace que para un tipo diferente de error ("No se pudo exportar como ").