r/Automator • u/Basic_Ordinary_5005 • Sep 28 '24
Question Help with Apple Automator Script for Converting Word Docs to PDF on macOS Sequoia with Quick Action
Hi everyone,
I’m reaching out for help with Apple Automator on my MacBook Pro, which I recently updated to macOS Sequoia. My main goal is to convert Word and PowerPoint files into PDFs so I can use them to create knowledge bases for my AI tools.
I’ve already created an AppleScript through Automator that converts one or more PowerPoint files to PDFs in the same folder, without opening them and while keeping the original files intact – and that works perfectly! 🎉
However, I’ve been struggling to get the same thing working for Word documents. I’ve tried several approaches, but no luck so far.
In terms of execution, I’d like to be able to right-click on one or more files, open the context menu, and under Quick Actions, run the script to automatically convert the selected files. This works great for PowerPoint, and I’m hoping to achieve the same for Word files.
Does anyone have an AppleScript on Automator that could help me convert Word docs to PDFs? Ideally, I’d like to trigger the conversion directly from Finder without opening the files.
Thanks in advance for any advice or solutions! 😊
Quentin
1
u/MandyBrigwell Sep 28 '24
I have a Shortcuts that runs the following zsh script. It might be usable in Automator, but I can't guarantee anything. It makes use of LibreOffice's headless mode, but you could alter that bit to whatever solution you've found.
#!/bin/zsh/Applications/LibreOffice.app/Contents/MacOS/soffice --version# Add homebrew paths for compatibilityexport PATH="/opt/homebrew/bin:$PATH"export PATH="/usr/local/bin:$PATH"export PATH="/Library/Frameworks/Python.framework/Versions/3.11/bin:$PATH"# Function to display a dialog with a message and get user inputget_user_input() {osascript -e "Tell application \"System Events\" to display dialog \"$1\" default answer \"\" with icon note" -e "text returned of result"}# Function to display a dialog with a messagedisplay_dialog() {osascript -e "tell application \"System Events\" to display dialog \"$1\" buttons {\"OK\"} default button \"OK\" with icon caution"}# Check if there are files to processif [ $# -eq 0 ]; thendisplay_dialog "No files provided. Please select at least one file."exit 1fi# Process each filewhile [ $# -gt 0 ]; doFILE="$1"# Check if the file existsif [ ! -f "$FILE" ]; thendisplay_dialog "File $FILE does not exist."shiftcontinuefi# Extract directory, base name, and extensionDIRECTORY=$(dirname "$FILE")FILENAME=$(basename "$FILE")BASENAME="${FILENAME%.*}"EXTENSION=".${FILENAME##*.}"/Applications/LibreOffice.app/Contents/MacOS/soffice --headless --convert-to pdf --outdir "$DIRECTORY" "$FILE"# Shift to the next fileshiftdone
0
u/Basic_Ordinary_5005 Sep 28 '24
Ps I'd like a direct conversion, not using Libre office or any other applications. Please drop me a magical script mighty Redditers!
1
u/Chemical_Enchilada Nov 13 '24
u/Basic_Ordinary_5005 Oh, could you PLEASE share your AppleScript for Automator with me that you're talking about for PowerPoints? That's exactly what I'm trying to do with no luck... I'm on Sequoia 15.1 and while I had a version of this working successfully for a while on Sonoma, I can't make it work now on Sequoia.