Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- repeat with i from 1 to number of items in draggedFiles
- set draggedFile to item i of draggedFiles
- set draggedFilePosix to POSIX path of draggedFile
- set quotedFilePosix to quoted form of draggedFilePosix
- # Get the file extension (lowercased)
- set fileExtension to do shell script "basename " & quotedFilePosix & " | awk -F. '{print tolower($NF)}'"
- # Check if the file is .doc or .docx
- if fileExtension is "doc" or fileExtension is "docx" then
- # Define output directory (same as input file directory)
- set outputDir to do shell script "dirname " & quotedFilePosix
- # Run LibreOffice headless conversion
- do shell script "/opt/homebrew/bin/soffice --headless --convert-to pdf --outdir " & quoted form of outputDir & " " & quotedFilePosix
- else
- display notification "Skipped " & draggedFilePosix & " (not a DOC or DOCX file)" with title "Dropzone LibreOffice PDF Converter"
- end if
- end repeat
- display notification "Conversion completed." with title "Dropzone LibreOffice PDF Converter"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement