Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (* Ask user to choose a .pages file. *)
- tell application "System Events"
- activate
- set n to ""
- try
- repeat while n does not end with ".pages"
- set file_name_alias to choose file with prompt "Please select a .pages file"
- tell disk item (file_name_alias as text)
- set n to name
- set d to path of container
- end tell
- end repeat
- on error -128 -- user cancelled
- return
- end try
- end tell
- (* Tell Pages to Save As .txt file. *)
- tell application "Pages"
- set pages_document_with_id to open file_name_alias
- set path_to_txt_document to (d as text) & n & ".txt"
- save pages_document_with_id as "SLDocumentTypePlainText" in path_to_txt_document
- close pages_document_with_id
- end tell
- (* Run shell script on the text file. All characters are replaced with 'a'. *)
- tell me
- set text_file_name to n & ".txt"
- set text_file_with_path to (d as text) & text_file_name
- set scramble_text to do shell script "cat " & POSIX path of file_name_alias & ".txt | sed 's/[a-z0-9A-Z]/a/g'"
- end tell
- (* Tell TextEdit to save scrambled text file. *)
- tell application "TextEdit"
- set save_path to POSIX path of (path to desktop folder)
- set temp_doc_id to make new document
- set text of temp_doc_id to scramble_text
- close temp_doc_id saving in save_path & "upload_me.txt"
- end tell
- (* clean up *)
- tell application "Finder"
- delete path_to_txt_document -- delete Pages' Save As .txt file
- end tell
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement