gpt4 book ai didi

file - Applescript:在Applescript创建后在查找器窗口中选择(突出显示)文件

转载 作者:行者123 更新时间:2023-12-02 03:52:35 24 4
gpt4 key购买 nike

我最近从 Windows 7 切换。我是 applescript 中的(非常)首次亮相。要通过热键和显示对话框创建新文件,我使用 spark 和以下脚本我部分发现:

try
tell application "Finder" to set the this_folder ¬
to (folder of the front window) as alias
on error -- Merci d ouvrir un dossier avec votre finder
set the this_folder to path to desktop folder as alias
end try

activate
set thefilename to text returned of (display dialog ¬
"Create file named:" default answer "filename.txt")
set thefullpath to POSIX path of this_folder & thefilename
do shell script "touch \"" & thefullpath & "\""

activate application "Finder"

我了解它的作用(shell 脚本触摸除外)。我成功地在需要时将显示对话框放在前面,然后输入 thefilename ,取景器窗口 this_folder .

我现在正在尝试选择/突出显示新创建的文件(以便在长列表中轻松找到它)。我找到了代码 open -R这可能是我正在寻找的,并尝试在底部应用它:
open -R thefilename


open -R this_folder/thefilename

我尝试重用变量 thefilename这是我之前输入的名称,未成功。我不知道如何指定打开命令可能显示的文件。

如果我的英语不完美,我深表歉意。

最佳答案

尝试:

try
tell application "Finder" to set the this_folder ¬
to (folder of the front window) as alias
on error -- Merci d ouvrir un dossier avec votre finder
set the this_folder to path to desktop folder as alias
end try


set thefilename to text returned of (display dialog ¬
"Create file named:" default answer "filename.txt")

tell application "Finder"
set thefullpath to make new file at folder this_folder with properties {name:thefilename}
select thefullpath
end tell

关于file - Applescript:在Applescript创建后在查找器窗口中选择(突出显示)文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13820485/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com