0

如果我的问题看起来很愚蠢,我只是一个初学者对不起。

现在我正在尝试编写一个脚本,将我所有的 .webarchive 转换为 .html,所以我最终使用名为“iCab”的应用程序打开 .webarchive 并将其保存到 .html

这是我的所有 .webarchive 在保存文件夹中的问题,我需要一个循环来一个一个地打开它,所以我可以把这段代码放在循环中

tell application "iCab" to open file file_name
tell application "iCab" to activate
delay 1
tell application "System Events"
    tell process "iCab"
        click menu item "Save As…" of menu "File" of menu bar 1
        key code 76
        click menu item "Close Window" of menu "File" of menu bar 1
    end tell
end tell

先感谢您

4

2 回答 2

7

您还需要将文件从 Finder 文件对象转换为别名。

tell application "Finder"
    set fl to files of folder POSIX file "/Users/username/Folder/" as alias list
end tell
repeat with f in fl
    tell application "iCab"
        open f
        activate
    end tell
    tell application "System Events"
        tell process "iCab"
            click menu item "Save As…" of menu "File" of menu bar 1
            keystroke return
            click menu item "Close Window" of menu "File" of menu bar 1
        end tell
    end tell
end repeat
于 2013-01-18T15:17:53.647 回答
1

尝试:

tell application "Finder" to set myFiles to every file of folder "Mac OS X:Users:Angeloid:Desktop:yourFolder"
repeat with aFile in myFiles
    --insert your code here
end repeat

编辑以包括选择文件夹:

tell application "Finder" to set myFiles to every file of (choose folder)
repeat with aFile in myFiles
    tell application "iCab"
        open file file_name
        activate
    end tell
    delay 1
    tell application "System Events"
        tell process "iCab"
            click menu item "Save As…" of menu "File" of menu bar 1
            key code 76
            click menu item "Close Window" of menu "File" of menu bar 1
        end tell
    end tell
end repeat
于 2013-01-18T15:04:29.463 回答