Use cloudconvert to convert pages files to pdf or any other

From your noodle to other noodles. Talk about ways to get the most from Hazel. Even exchange recipes for the cool rules you've thought up. DO NOT POST YOUR QUESTIONS HERE.

Moderators: Mr_Noodle, Moderators

Use Hazel and script to implement a routine for convert pages files to pdf or any other supported file by cloudconvert.
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]
David Ortner
 
Posts: 1
Joined: Sun Jan 29, 2017 6:36 am

Return to Tips & Tricks - DO NOT POST QUESTIONS