Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Another idea would be to create a template of the desired folder structure somewhere, then have the script copy that structure with the client prefix. A couple of benefits to this method are that you don't need to change the script if folders are added to the template (the handler will also add to existing structures), and you don't have to figure out how to script complex (or large) structures.</p> <pre><code>property template : "/path/to/template/folder" -- the folder structure to copy from on run -- example set jobNum to text returned of (display dialog "Enter a job number:" default answer "[JobNumber]-[Description]") set folderPath to (choose folder with prompt "Select a location for the client folder") tell application "Finder" to try set clientFolder to (make new folder at folderPath with properties {name:jobNum}) on error number -48 -- folder already exists set clientFolder to (folderPath as text) &amp; jobNum end try copyFolderStructure_toFolder_withPrefix_(template, clientFolder, jobNum) end run to copyFolderStructure_toFolder_withPrefix_(source, destination, additions) -- copy folder structure using mkdir set {source, destination} to {source as text, destination as text} if source begins with "/" then set source to POSIX file source if destination begins with "/" then set destination to POSIX file destination set {source, destination} to {source as alias, destination as alias} set additions to additions as text tell application "Finder" to set theFolders to (folders of entire contents of source) as alias list set folderNames to "" repeat with someFolder in theFolders -- set up the folder names parameter for the shell script set {tempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ":"} set namePieces to text items of (text ((count (source as text)) + 1) thru -2 of (someFolder as text)) set AppleScript's text item delimiters to ("/" &amp; additions) set namePieces to space &amp; quoted form of (additions &amp; (namePieces as text)) set AppleScript's text item delimiters to tempTID set folderNames to folderNames &amp; namePieces end repeat do shell script "cd " &amp; quoted form of POSIX path of destination &amp; "; mkdir -p" &amp; folderNames end copyFolderStructure_toFolder_withPrefix_ </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload