我一直在尋找試圖找出如何執行此腳本的留言板。實質上,目標是能夠在文件夾內運行此腳本,並且如果某些文件夾不存在,則會創建這些文件夾。如果它們已經存在,則什麼都不會發生。這是我迄今拼湊在一起的東西:AppleScript:如果不存在新的文件夾結構
property archivesFolder : "Archives"
property imagesFolder : "Images"
property proofreadFolder : "Proofreading"
property proofFolder : "Proofs"
property sourceFolder : "Source"
try
tell application "Finder" to set theLocation to (folder of the front window as alias)
end try
tell application "Finder"
if (exists folder archivesFolder) then
(* do nothing *)
else
make new folder at theLocation with properties {name:archivesFolder}
end if
if (exists folder imagesFolder) then
(* do nothing *)
else
make new folder at theLocation with properties {name:imagesFolder}
end if
if (exists folder proofreadFolder) then
(* do nothing *)
else
make new folder at theLocation with properties {name:proofreadFolder}
end if
if (exists folder proofFolder) then
(* do nothing *)
else
make new folder at theLocation with properties {name:proofFolder}
end if
if (exists folder sourceFolder) then
(* do nothing *)
else
make new folder at theLocation with properties {name:sourceFolder}
end if
end tell
我在做什麼錯? (原諒我的n00b代碼格式,在工作中,無法弄清楚如何創建代碼塊)另外,這可能不僅僅是在前窗上,而是在剛剛選擇的文件夾上?任何幫助都會很棒。
我實際上已將它設置爲選項1,並且如果文件夾中沒有任何內容,它工作正常。但是,如果我刪除這些文件夾中的一個,它會破壞代碼,它什麼也不做。我希望它能夠在不是所有文件夾都存在的情況下工作,但有些可能已經存在(這取決於誰設置了原始文件夾)。 – user1231499 2012-02-24 19:50:29
@ user1231499在這裏你走!如果這爲你工作,請批准答案。 – jackJoe 2012-02-24 20:11:44
就像魔術一樣,它很有效。我認爲每種情況都可能存在某種路徑,但我認爲我只是嘗試了一些東西,比如在「位置」處添加「並停止工作」。非常感謝,這將是偉大的! 實際上,不會有這樣的設置方式,如果你只是簡單地選擇文件夾就會運行,或者只有當文件夾位於打開窗口時才真正可行? – user1231499 2012-02-24 20:54:45