Hi
i’m a novice to apple scripting and i have got lost trying to create an app for making multiple levels of folders with set names when i drop the named folder on the scrip icon from the finder. I’m want to create 5 levels of folders. Can anyone please advise. thanks
property level1 : {“AW”, “Ads”, “Pics”, “Vis”, “FOH”, “Video”, “Logos”, “3D”, “Gifts”, “Misc”, “Pch”}
property level2 : {{“AW”, “-AW-2011”, “-AW-2012”}, {“Ads”, “-Ads-2011”, “-Ads-2012”, “-AdPicLog”}, {“Vis”, “-Vis-2011”, “-Vis-property temp : {”"}
global thetopLevel, showName, abbName
on open of theFiles
repeat with theFolder in theFiles
tell application “Finder” to set theFlag to exists of folder (theFolder as text)
if theFlag then
makeFolders(theFolder as text)
else
activate
beep
display dialog (theFolder as text) & " is not a folder. Cannot be processed!" buttons {“OK”} default button 1 with icon caution giving up after 4
end if
end repeat
activate
display dialog “Completed”
end open
on makeFolders(thetopLevel)
set AppleScript’s text item delimiters to {“:”}
set showName to (text item ((count of text items of thetopLevel) - 1) of thetopLevel) as text
set AppleScript’s text item delimiters to temp
tell application “Finder”
activate
repeat
set theR to display dialog “Enter the abbreviated Name” default answer showName buttons {“Cancel”, “OK”} default button 2
set theR to (text returned of theR) as text
if ((length of theR) + 9) ≥ 31 then
beep
display dialog “Name is too long! Please abbreviate the name (maximum of 21 characters)” buttons {“Cancel”, “OK”} default button 2 with icon caution
else
set abbName to theR
exit repeat
end if
end repeat
open folder thetopLevel
repeat with l1 in level1
set thel1Folder to thetopLevel & abbName & “-” & (l1 as text) & “:”
if (not (exists of folder thel1Folder)) then
make new folder at folder thetopLevel with properties {name:(abbName & “-” & (l1 as text))}
end if
repeat with addFolders from 1 to count of items of level2
if (item addFolders of level2) contains (l1 as text) then
copy (item addFolders of level2) to theAFolders
repeat with i from 2 to count of items of theAFolders
copy (item addFolders of level2) to theAFolders
repeat with i from 2 to count of items of theAFolders
if (not (exists of folder (thel1Folder & abbName & ((item i of theAFolders) as text)))) then
make new folder at folder thel1Folder with properties {name:(abbName & ((item i of theAFolders) as text))}
end if
end repeat
end if
end repeat
end repeat
end tell
end makeFolders