Page 1 of 1

Use cloudconvert to convert pages files to pdf or any other

PostPosted: Sun Jan 29, 2017 6:48 am
by David Ortner
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]

Re: Use cloudconvert to convert pages files to pdf or any ot

PostPosted: Tue Jan 05, 2021 9:29 pm
by NoodleNewbie
Hello David

Would you be available to help me get this going?
CloudConvert api is now version 2
https://cloudconvert.com/api/v2#overview

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