用于将HTML转换为纯文本的Applescript(或自动机器人动作)

时间:2015-12-15 17:10:16

标签: applescript

我有一个Applescript或Automator动作让我选择文件,然后它会将HTML转换为纯文本。不知怎的,我可能已经失去了那个剧本。

我认为脚本是下面的脚本,但是当我使用它并选择一些文件时,它会将其中的一些文件转换为.rtf然后它们就会消失。奇异。

非常感谢任何帮助。

set ASTID to AppleScript's text item delimiters

choose file with multiple selections allowed without invisibles
repeat with thisFile in result
    try
        set thisFile to POSIX path of thisFile

        do shell script "/usr/bin/textutil -convert rtf " & quoted form of result

        set AppleScript's text item delimiters to {"."}
        set thisFile to text items 1 through -2 of thisFile
        set AppleScript's text item delimiters to {""}
        set thisFile to thisFile as text

        do shell script "/System/Library/Printers/Libraries/convert" & ¬
            " -f " & quoted form of (result & ".rtf") & ¬
            " -o " & quoted form of (result & ".pdf") & ¬
            "; /bin/rm -f " & quoted form of (result & ".rtf")
    on error errorMsg number errorNum
        display dialog "Error (" & errorNum & "):" & return & return & errorMsg buttons "Cancel" default button 1 with icon caution
    end try
end repeat
set AppleScript's text item delimiters to ASTID

0 个答案:

没有答案