假设我有一堆具有类似子路径的文件夹:
Folder 1
Do
Re
Mi
<Files>
Folder 2
Do
Re
Mi
<Different Files>
我知道我可以使用tell application Finder to open "Macintosh HD:Users: ...
打开文件夹。是否有任何方法可以将弹出窗口排队以选择我要输入的Folder 1
或Folder 2
中的哪一个,然后将其输入上述命令?例如,如果我选择Folder 1
,则会转到...Folder 1/Do/Re/Mi
,而如果我选择Folder 2
,则转到...Folder 2/Do/Re/Mi
。
我尝试过的一件事是将do shell script
与concatenate结合起来以获取do shell script "open " & variable & "/Do/Re/Mi/"
,但如果文件名不止一个,则代码会失败。
答案 0 :(得分:0)
例如(将baseFolder
设置为Folder 1
和Folder 2
的父文件夹的别名
set baseFolder to path to home folder
set folderList to {}
tell application "Finder" to set allFolders to name of folders of baseFolder
repeat with i from 1 to (count allFolders)
set end of folderList to (i as text) & space & item i of allFolders
end repeat
set chosenItem to choose from list folderList
if chosenItem is false then return
set chosenIndex to word 1 of item 1 of chosenItem
set selectedFolder to item chosenIndex of allFolders
set destinationFolder to (baseFolder as text) & selectedFolder & ":Do:Re:Mi:"
tell application "Finder"
if exists folder destinationFolder then
open folder destinationFolder
else
display dialog "Sorry, the folder does not exist"
end if
end tell