【发布时间】:2022-10-26 04:26:17
【问题描述】:
出于某种原因,Mac 上的 Finder 不具备创建新文件的功能。我发现创建新文件的最快方法是将查找器路径拖到终端并在那里创建一个文件......这非常烦人
我编写了一个苹果脚本来自动创建一个新文件并将其绑定到一个快捷方式。它工作得很好,除了我不知道如何打开applescript 中的新文件。我很确定错误源于 POSIX / UNIX 路径,但即使我将 POSIX 放在文件、currentDir 等旁边,也找不到让它工作的方法。
这是我的脚本:
set file_name to display dialog "File Name" default answer "untitled" with icon note buttons {"Cancel", "Continue"} default button "Continue"
set file_name to (text returned of file_name)
tell application "Finder"
set theWin to window 1
set currentDir to POSIX path of (target of theWin as alias)
make new file at (the target of the front window) as alias with properties {name:file_name}
set currentPath to (currentDir & file_name) as string
open file currentPath
end tell
该脚本创建文件,然后出错说它找不到文件来打开它。
【问题讨论】:
标签: file applescript