The routine is triggered by ad or updating files in specific folder. On https://cloudconvert.com you find you api key. PDF file are saved in same folder with same name. This solution is much better than using pages because the program is constantly being updated and changed.
- Code: Select all
set CLOUDCONVERT_APIKEY to "your api key"
-- Get POSIX file path
set inputFilePath to POSIX path of theFile
-- Remove .pages extension.
set prevTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to ".pages"
-- Add .pdf extension.
set outputFilePath to first text item of inputFilePath & ".pdf"
set AppleScript's text item delimiters to prevTIDs
set theDate to short date string of (get current date)
set theTime to time string of (get current date)
set theMessage to theDate & " " & theTime & " converting " & inputFilePath & " into " & outputFilePath
do shell script "echo \"" & theMessage & "\" >> ~/Library/Logs/Hazel-AppleScript.log"
set theCurl to do shell script "curl -L \"https://api.cloudconvert.com/convert\" -F file=@\"" & inputFilePath & "\" -F \"apikey=" & CLOUDCONVERT_APIKEY & "\" -F \"inputformat=pages\" -F \"outputformat=pdf\" -F \"input=upload\" -F \"wait=true\" -F \"download=inline\" > \"" & outputFilePath & "\""
[img]
www.eli.systems/Bilder/2017-01-29_11-45-00.png
www.eli.systems/Bilder/2017-01-29_11-45-00.png
[/img]