Created
February 1, 2016 12:38
-
-
Save konn/89527e041cdfb16c9404 to your computer and use it in GitHub Desktop.
Dvipdfmx Droplet for Old UpTeX.app (〜2011?)
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
property dvipdfmx : "/Applications/UpTeX.app/teTeX/bin/dvipdfmx" | |
on split(s, targ) | |
set oldDelims to AppleScript's text item delimiters | |
set AppleScript's text item delimiters to s | |
set theList to every text item of targ | |
set AppleScript's text item delimiters to oldDelims | |
return theList | |
end split | |
on join(s, theList) | |
set oldDelims to AppleScript's text item delimiters | |
set AppleScript's text item delimiters to s | |
set theText to theList as text | |
set AppleScript's text item delimiters to oldDelims | |
return theText | |
end join | |
on fileNameOf(theFile) | |
return the last item of split("/", POSIX path of theFile) | |
end fileNameOf | |
on dirNameOf(theFile) | |
return join("/", items 1 thru -2 of split("/", POSIX path of theFile)) | |
end dirNameOf | |
on open theList | |
main(theList) | |
end open | |
on main(theList) | |
repeat with theFile in theList | |
set target to fileNameOf(theList) | |
set defLoc to dirNameOf(theFile) | |
set message to target & "のPDF変換後の保存先を指定してください" | |
set dviPath to choose file name with prompt message ¬ | |
default name (join(".dvi", items 1 thru -2 of split(".dvi", target)) & ".pdf") ¬ | |
default location defLoc | |
try | |
do shell script (dvipdfmx & " -o " & POSIX path of dviPath & " " & POSIX path of theFile) | |
set opt to the button returned of (display dialog (target & "の変換が完了しました。開きますか?") ¬ | |
buttons {"キャンセル", "Finderに表示", "PDFを表示"} ¬ | |
default button "PDFを表示") | |
if opt = "PDFを表示" then | |
tell application "Finder" to open dviPath | |
else if opt = "Finderに表示" then | |
tell application "Finder" to select dviPath | |
end if | |
on error | |
display alert (target & "の処理に失敗しました。") | |
end try | |
end repeat | |
end main | |
on run | |
set theFile to choose file with prompt "変換するdviファイルを選んで下さい" of type {"dvi"} | |
main({theFile}) | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment