The script uses a Template Folder. The folder is in Documents.
/Users/UserName/Documents/template_job_folder
inside this is where you have all your Set/template folders and template files inside of them.
The script prompts you to choose which Set you want.
It then Prompts you to choose which of the Sub Folders you want from that set.
You can choose more than one. Apple + A to select ALL
Next choose where to create them.
It will make a new folder with the name of the Set you chose at the destination you also chose.
Then copy Only the Sub folders you chose to the New set folder. In the process it will also copy the contents of the sub folders.
Remember, you MUST have the /Users/UserName/Documents/template_job_folder
set up with your Folder sets first before running this
property the_doc_folder : path to documents folder from user domain as string
property Temp_folder : "template_job_folder"
set Templist to {}
set subList to {}
tell application "Finder"
set these_items to folder Temp_folder of folder the_doc_folder as string
set thecounter to 0
repeat count of (every item of folder these_items whose (class is folder)) times
set thecounter to thecounter + 1
copy displayed name of (item thecounter of folder these_items whose (class is folder)) to end of Templist
end repeat
set folderType to (choose from list Templist with prompt "Which folder set do you want?" without multiple selections allowed) as text
--
set folder_Type to folder folderType of folder Temp_folder of folder the_doc_folder as string
set thecounter to 0
repeat count of (every item of folder folder_Type whose (class is folder)) times
set thecounter to thecounter + 1
copy displayed name of (item thecounter of folder folder_Type whose (class is folder)) to end of subList
end repeat
set folderSubs to (choose from list subList with prompt "Select the Sub Folders you want?" with multiple selections allowed and empty selection allowed) as list
set myPath to (choose folder with prompt "Where do you want the set made?") as text
make new folder at folder myPath with properties {name:folderType}
end tell
set subcount to 0
repeat count of items in folderSubs times
set subcount to subcount + 1
set Sub_folder to POSIX path of these_items & folderType & "/" & item subcount of folderSubs & "/"
set dest_folder to POSIX path of myPath & folderType & "/"
set dest_ to do shell script " echo " & dest_folder & " | sed 's/\\ /\\\\ /g'"
set sub_Job to do shell script " echo " & item subcount of folderSubs & "/" & " | sed 's/\\ /\\\\ /g'"
set sub_Job_Name to sub_Job
do shell script "cp -R /" & "\"" & Sub_folder & "\" " & dest_folder & sub_Job_Name & "\"" & "\""
end repeat
That would appear to solve the problem of figuring out how to get the template files in the folders eventually.
That works pretty slick.
So, the idea is to set this up on 4-5 Account Exec. machines. Instead of having the template files and folders in their docurments folders, would it be possible to set up this folder on our Server? and have it pull from there?
Just updated the script so it handles if the user “Cancels” any where along the process.
As to doing this from the server it should be possible.
I think all you have to do is change the paths to the template folder.
And make sure the server space is mounted.
**EDIT
When i test this on my .mac ( only thing I can mount at the mo)
I use
property the_doc_folder : alias “Macintosh HD:volumes:dotmacname” as string
When I compile. Script Editor sets it to
property the_doc_folder : alias “dotmacname:” as string
So long as the volume is mounted it works.
**end edit
property the_doc_folder : path to documents folder from user domain as string
property Temp_folder : "template_job_folder"
set Templist to {}
set subList to {}
set theresult to ""
tell application "Finder"
set these_items to folder Temp_folder of folder the_doc_folder as string
set thecounter to 0
repeat count of (every item of folder these_items whose (class is folder)) times
set thecounter to thecounter + 1
copy displayed name of (item thecounter of folder these_items whose (class is folder)) to end of Templist
end repeat
set folderType to (choose from list Templist with prompt "Which folder set do you want?" without multiple selections allowed) as text
if result is not "false" then
set theresult to "true"
set folder_Type to folder folderType of folder Temp_folder of folder the_doc_folder as string
set thecounter to 0
repeat count of (every item of folder folder_Type whose (class is folder)) times
set thecounter to thecounter + 1
copy displayed name of (item thecounter of folder folder_Type whose (class is folder)) to end of subList
end repeat
else
end if
if theresult is "true" then
set folderSubs to (choose from list subList with prompt "Select the Sub Folders you want?" with multiple selections allowed) as list
set theReturn to result as string
if theReturn is not "false" then
set myPath to (choose folder with prompt "Where do you want the set made?") as text
if result is not "false" then
set theresult to "true"
make new folder at folder myPath with properties {name:folderType}
set subcount to 0
repeat count of items in folderSubs times
set subcount to subcount + 1
set Sub_folder to POSIX path of these_items & folderType & "/" & item subcount of folderSubs & "/"
set dest_folder to POSIX path of myPath & folderType & "/"
set dest_ to do shell script " echo " & dest_folder & " | sed 's/\\ /\\\\ /g'"
set sub_Job to do shell script " echo " & item subcount of folderSubs & "/" & " | sed 's/\\ /\\\\ /g'"
set sub_Job_Name to sub_Job
do shell script "cp -R /" & "\"" & Sub_folder & "\" " & dest_folder & sub_Job_Name & "\"" & "\""
end repeat
end if
end if
else
end if
end tell
I am new to AppleScript and would like some help on setting up a script that can create subfolders.
What I would like is for the script to create the subfolders and name them according to the file names that are been placed in the HiRes Images folder.
Here’s my structure:
Folder: HiRes Images
Subfolders: 01 SubSubfolders: 0100, 0154, 0187, etc.
Subfolders: 02 SubSubfolders: 0200, 0209, 0290, etc.
So if I place image 015487_.eps in the HiRes folder, the script should create a subfolder 01 if it does not exist and in that 01 folder create another subsufolder 0154 if it does not exist and place image 015487_.eps in it. The script should not overwrite existing subfolders, but just sort the image.
property the_doc_folder : alias "RAID:Resources (Creative):"
property Temp_folder : "Folder Templates"
set Templist to {}
set subList to {}
set theresult to ""
tell application "Finder"
set these_items to folder Temp_folder of folder the_doc_folder as string
set thecounter to 0
repeat count of (every item of folder these_items whose (class is folder)) times
set thecounter to thecounter + 1
copy displayed name of (item thecounter of folder these_items whose (class is folder)) to end of Templist
end repeat
set folderType to (choose from list Templist with prompt "Which folder set do you want?" without multiple selections allowed) as text
if result is not "false" then
set theresult to "true"
set folder_Type to folder folderType of folder Temp_folder of folder the_doc_folder as string
set thecounter to 0
repeat count of (every item of folder folder_Type whose (class is folder)) times
set thecounter to thecounter + 1
copy displayed name of (item thecounter of folder folder_Type whose (class is folder)) to end of subList
end repeat
else
end if
if theresult is "true" then
set folderSubs to (choose from list subList with prompt "Select the Sub Folders you want?" with multiple selections allowed) as list
set theReturn to result as string
if theReturn is not "false" then
set myPath to (choose folder with prompt "Where do you want the set made?") as text
if result is not "false" then
set theresult to "true"
make new folder at folder myPath with properties {name:folderType}
set subcount to 0
repeat count of items in folderSubs times
set subcount to subcount + 1
set Sub_folder to POSIX path of these_items & folderType & "/" & item subcount of folderSubs & "/"
set dest_folder to POSIX path of myPath & folderType & "/"
set dest_ to do shell script " echo " & dest_folder & " | sed 's/\\ /\\\\ /g'"
set sub_Job to do shell script " echo " & item subcount of folderSubs & "/" & " | sed 's/\\ /\\\\ /g'"
set sub_Job_Name to sub_Job
do shell script "cp -R /" & "\"" & Sub_folder & "\" " & dest_folder & sub_Job_Name & "\"" & "\""
end repeat
end if
end if
else
end if
end tell
Offhand, I’d say there might be some “tell block madness” going on. (That can apply to regular scripts too.) Also, you may want to consider using quoted form with that shell script.