2013-07-02 149 views
1

我有一個Applescript用於創建作業文件夾。 Applescript要求輸入項目名稱和文件夾的存儲位置。輸入作業名稱和文件夾位置後,該腳本將創建主文件夾和四個子文件夾。創建文件夾Applescript

現在我想讓腳本在當前子文件夾之一中創建編號的子文件夾,並提示詢問用戶要創建多少個文件夾。那可能嗎?

tell application "Finder" 
    set JobName to text returned of (display dialog "Please enter Job Name:" default answer "Job_Name") 
    set loc to choose folder "Choose Parent Folder Location" 
    set newfoldername to JobName 
    set newfo to make new folder at loc with properties {name:newfoldername} 
    make new folder at newfo with properties {name:"Job Materials"} 
    make new folder at newfo with properties {name:"Previews"} 
    make new folder at newfo with properties {name:"PSDs"} 
    make new folder at newfo with properties {name:"VX"} 
end tell 

回答

3
set JobName to text returned of (display dialog "Please enter Job Name:" default answer "Job_Name") 
set loc to choose folder "Choose Parent Folder Location" 

tell application "Finder" 
    set newfo to make new folder at loc with properties {name:JobName} 
    make new folder at newfo with properties {name:"Job Materials"} 
    make new folder at newfo with properties {name:"Previews"} 
    set targetFolder to make new folder at newfo with properties {name:"PSDs"} 
    make new folder at newfo with properties {name:"VX"} 
end tell 

repeat 
    set subCount to text returned of (display dialog "How many subfolders?" default answer 3) 
    try 
     if subCount ≠ "" then 
      subCount as integer 
      exit repeat 
     end if 
    end try 
end repeat 

repeat with i from 1 to subCount 
    tell application "Finder" to make new folder at targetFolder with properties {name:"Subfolder " & i} 
end repeat