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 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 \"\" -F file=@\"" & inputFilePath & "\" -F \"apikey=" & CLOUDCONVERT_APIKEY & "\" -F \"inputformat=pages\" -F \"outputformat=pdf\" -F \"input=upload\" -F \"wait=true\" -F \"download=inline\" > \"" & outputFilePath & "\""

David Ortner
Posts: 1
Joined: Sun Jan 29, 2017 6:36 am

Hello David

Would you be available to help me get this going?
CloudConvert api is now version 2

I can write Hazel Rules, running an embedded shell script (that effectively calls a python3 script passing parameters, if the script is already written). But I do not know how to write the shell script. Do you have a python script that works, that I can copy and use?

i wish to convert epub to azw3 files
The file is either on my dropbox (connected to cloudconvert, now available)
or I grab the file from my computer

I would rather create a watch folder on my computer, and hazel execute every time I put a file in the "watch folder"

Thankyou for any assistance
Posts: 34
Joined: Fri Jul 13, 2018 5:17 pm

Return to Tips & Tricks - DO NOT POST QUESTIONS