Created
March 5, 2017 14:22
-
-
Save neosarchizo/1a8098371fc731c97c09ad76389df01f to your computer and use it in GitHub Desktop.
Save as pdf by applescript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set AppleScript's text item delimiters to ".pdf" | |
repeat while true | |
tell application "System Events" | |
tell process "Your Application" | |
if exists window "Print" then | |
tell window "Print" | |
if not (exists sheet 1) then | |
click menu button "PDF" | |
repeat until exists menu item "Save as PDF…" of menu 1 of menu button "PDF" | |
end repeat | |
click menu item "Save as PDF…" of menu 1 of menu button "PDF" | |
repeat until exists sheet 1 | |
end repeat | |
tell sheet 1 | |
set maxFileNumber to 0 | |
tell application "Finder" | |
set fileList to name of every file of folder "Macintosh HD:Users:neosarchizo:Downloads:" | |
repeat with currentFile in fileList | |
if ".pdf" is in currentFile then | |
set currentFileNumber to (text item 1 of currentFile) as integer | |
if currentFileNumber > maxFileNumber then | |
set maxFileNumber to currentFileNumber | |
end if | |
end if | |
end repeat | |
set maxFileNumber to maxFileNumber + 1 | |
end tell | |
keystroke maxFileNumber | |
click button "Save" | |
end tell | |
end if | |
end tell | |
end if | |
end tell | |
end tell | |
end repeat |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment