Applescript逐个打开文件夹中的所有文件

0 applescript

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

现在我正在尝试编写一个脚本,将我所有的.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
Run Code Online (Sandbox Code Playgroud)

先感谢您

Lri*_*Lri 5

您还需要将文件从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
Run Code Online (Sandbox Code Playgroud)