4

私は最近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"

私はそれが何をするのか理解しています(シェルスクリプトタッチを除く)。必要に応じて表示ダイアログを前面に配置し、入力後、ファインダーウィンドウ
を配置することに成功しました。thefilenamethis_folder

私は今、新しく作成されたファイルを選択/ハイライトしようとしています(長いリストで簡単に見つけるために)。open -R私はおそらく私が探しているものであるコードを見つけて、これを下部に適用しようとします:

open -R thefilename

open -R this_folder/thefilename

thefilename以前に入力した名前の変数を再利用しようとしましたが、失敗しました。
openコマンドで表示される可能性のあるファイルを指定する方法がわかりません。

私の英語が完璧でない場合はお詫び申し上げます。

4

1 に答える 1

2

試す:

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
于 2012-12-11T12:44:54.450 に答える