我刚刚创建了一个脚本,可以让我在当前关注的Finder窗口中创建一个空白的无标题文件,然后专注于该文件以快速重命名。
我希望使用内置的新文本文件对话框,但没有文件格式和编码。
有没有办法创建这个对话框?
以下是我在当前位置创建新文件的方法:
on run {input, parameters}
try
tell application "Finder"
set wasFolder to true
set selectedFolder to first item of input
set selectedType to (kind of (info for selectedFolder))
if selectedType is not in {"Folder", "Volume"} then
set selectedFolder to container of selectedFolder as string
set wasFile to false
end if
end tell
tell application "Finder"
activate
set theFile to make new file at folder selectedFolder
if selectedFolder as string is equal to (path to desktop as string) then
select window of desktop
set selection to theFile as alias
else
reveal theFile
end if
end tell
tell application "System Events"
tell process "Finder"
if wasFolder then delay 0.4
keystroke return
end tell
end tell
on error errMsg
display dialog "Error: " & errMsg
end try
end run
答案 0 :(得分:0)
你可以尝试一些......
set userResonse to text returned of (display dialog "Enter a name..." default answer "response" buttons {"Cancel", "OK"} default button "OK")
tell application "Finder"
if exists Finder window 1 then
make new file at (target of front Finder window as text) with properties {name:userResonse}
else
make new file at (path to desktop) with properties {name:userResonse}
end if
end tell
答案 1 :(得分:-1)
您现在可以从Mac App Store获取New File Menu。它带有一个可自定义的首选项菜单,可让您创建具有特定扩展名的新文件。