Q: Applescript help
Hi, I am trying to create a script that allows me to generate a set folder structure on a network volume.
I currently have the below script that works great but generates the folder to the desktop.
How would I change this to include a dialog box that would allow me to navigate to a specific folder within a network volume?
I.e. it would take me to the top level of the volume and allow me to select from the subfolder structure my desired location for the folders to generate.
Any help would be much appreciated.
Thanks
Sam
global jobNum
set ThePath to path to desktop -- the location to make the folder structure
set textYear to text -2 through -1 of ((current date)'s year as text)
set jobNum to text returned of (display dialog "Please enter Job Number:" default answer {textYear & "xxx"})
set JobName to text returned of (display dialog "Please enter Job Name:" default answer "Job Name")
set JobNumName to jobNum & "_" & JobName
makeFolderStructure out of {JobNumName, {jobNum & "_" & "AW_Elements", {jobNum & "_" & "AW_Downloads", jobNum & "_" & "AW_Approvals", jobNum & "_" & "AW_Links", {"eps-tiff", "jpg", "psd", "ai"}, jobNum & "_" & "AW_PDF", {"Hires", "Lores"}, jobNum & "_" & "AW_Photography", jobNum & "_" & "AW_Presenters", jobNum & "_" & "AW_Resource", jobNum & "_" & "AW_Gone_to_Print"}, jobNum & "_" & "MG_Elements", {jobNum & "_" & "MG_Downloads", jobNum & "_" & "MG_Renders", {"Lores", "Final"}, jobNum & "_" & "MG_Imports", {"ai", "audio", {"Bought", "Reference"}, "eps-tif", "jpg", "psd", "video"}, jobNum & "_" & "MG_Resource"}, jobNum & "_" & "CR_Elements", {jobNum & "_" & "CR_Presenters", jobNum & "_" & "CR_Downloads", {"Bought", "Reference"}, jobNum & "_" & "CR_Photography", jobNum & "_" & "CR_Resource", jobNum & "_" & "CR_Scamps", jobNum & "_" & "CR_Copy", jobNum & "_" & "CR_Working", {"illustrator", "indesign", "photoshop"}}}} at ThePath
to makeFolderStructure out of someItem at someFolder
set parentFolder to someFolder
if class of someItem is list then
repeat with anItem in someItem
if class of anItem is list then -- add subfolder(s)
makeFolderStructure out of anItem at someFolder
else -- add a new child folder at the current parent
log anItem
tell application "Finder"
make new folder at parentFolder with properties {name:anItem}
set someFolder to the result as alias
if anItem begins with jobNum & "_AW_" then set label index of someFolder to 6 -- green
if anItem begins with jobNum & "_CR_" then set label index of someFolder to 3 -- yellow
if anItem begins with jobNum & "_MG_" then set label index of someFolder to 5 -- purple
if anItem contains "CR_Presenters" then
set lanFile to file "XXXXXXX_CR_presenter_STX_VX.indd" of folder "Presenter_Master" of disk "Macintosh HD"
duplicate {lanFile} to someFolder
end if
end tell
end if
end repeat
else -- add a single folder
tell application "Finder"
make new folder at someFolder with properties {name:someItem}
set parentFolder to the result as alias
if someItem begins with jobNum & "_AW_" then set label index of parentFolder to 6 -- green
if someItem begins with jobNum & "_CR_" then set label index of parentFolder to 3 -- yellow
if someItem begins with jobNum & "_MG_" then set label index of parentFolder to 5 -- purple
end tell
end if
end makeFolderStructure
glo
OS X Mountain Lion (10.8.5)
Posted on Aug 10, 2016 9:50 AM
Thats perfect, thanks Niel
Posted on Aug 19, 2016 1:15 AM
