我試圖用AppleScript在Finder中打開一個文件夾。以下是我的代碼。我想要在Finder中打開文件夾WorkSpace
,但它會打開父文件夾/Volumes/MyMacDrive/Mani
並突出顯示WorkSpace
文件夾。我想要WorkSpace
文件夾的內容,但是我得到的是其父文件夾的內容。我在這裏錯過什麼..?AppleScript:在Finder中打開文件夾
property the_path : "/Volumes/MyMacDrive/Mani/WorkSpace/"
set the_folder to (POSIX file the_path) as alias
tell application "Finder"
activate
if window 1 exists then
set target of window 1 to the_folder
else
reveal the_folder
end if
end tell
使用'搜索window'如果其中一個窗口是打開的(信息窗口,首選項窗口,剪切窗口和視圖選項窗口),則代替「窗口」的窗口不會出現錯誤。 - >'如果Finder窗口1存在然後'。 reveal命令:將指定的對象帶入** view **,使用'open'命令,如** adayzdone **的答案。 – jackjr300