Advertisement
Guest User

Untitled

a guest
Jun 10th, 2025
5
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. repeat with i from 1 to number of items in draggedFiles
  2. set draggedFile to item i of draggedFiles
  3. set draggedFilePosix to POSIX path of draggedFile
  4. set quotedFilePosix to quoted form of draggedFilePosix
  5.  
  6. # Get the file extension (lowercased)
  7. set fileExtension to do shell script "basename " & quotedFilePosix & " | awk -F. '{print tolower($NF)}'"
  8.  
  9. # Check if the file is .doc or .docx
  10. if fileExtension is "doc" or fileExtension is "docx" then
  11. # Define output directory (same as input file directory)
  12. set outputDir to do shell script "dirname " & quotedFilePosix
  13.  
  14. # Run LibreOffice headless conversion
  15. do shell script "/opt/homebrew/bin/soffice --headless --convert-to pdf --outdir " & quoted form of outputDir & " " & quotedFilePosix
  16. else
  17. display notification "Skipped " & draggedFilePosix & " (not a DOC or DOCX file)" with title "Dropzone LibreOffice PDF Converter"
  18. end if
  19. end repeat
  20.  
  21. display notification "Conversion completed." with title "Dropzone LibreOffice PDF Converter"
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement