File Applescript:由Applescript创建后,在finder窗口中选择(突出显示)一个文件

File Applescript:由Applescript创建后,在finder窗口中选择(突出显示)一个文件,file,applescript,File,Applescript,我最近从Windows7切换。我是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

我最近从Windows7切换。我是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 script touch外)。
在需要时,我成功地将显示对话框放在前面,并在输入文件名后,打开finder窗口
此文件夹

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

open -R thefilename

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

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

试试:

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
谢谢!我只是在第二段和第三段之前做广告“激活”!
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