title: AppleScript: How to add numbers in front of folder and sub folder name?
body: <p>How to add numbers in front of folder and sub folder name?</p>
  
  <p>I have my script here for a "Folder Maker" and I can add a number on the main folder but how does one keeps adding same number for all the folders and subfolders inside? Please help. Thank you.</p>
  
  <pre class="lang-applescript prettyprint-override"><code>property structure : {"Contract Proposals", {"Contracts and proposals", {"Owner", "Architect", "Consultant", "General contractor"}, "Scope of work"}, "Existing Conditions", {"Base building information", "Owner provided drawing (can be CAD)", "Lease documents", "Building reports/environmental reports", "Surveys"}, "Programming", {"Questionnaires/spreadsheets", "Interviews/meeting minutes", "Adjacency matrix and diagrams"}, "Code-Permit", {"Approvals", "Zoning/building permit applications", "Permit documentation submitted", "Research section scanned", "Summary of code research", "Correspondence"}, "Design Sketches", {"Existing conditions (field verified)", {"Sk0"}, "Schematic design", {"Preliminaries", "Sk1 through x"}, "Design development", {"Sk1 thru x"}, "Renderings/presentations (dated)"}, "Construction Documentation", {"Construction documents (dated)", {"Sheet specs"}, "Specifications", "ComCheck/resCheck", "Supplemental drawings (dated)", {"Sd1 thru x"}, "Bulletins/addenda", "Design info/backgrounds (to/from consultants)"}, "Bidding", {"List of contractors", "Instructions to bidders", "Bids received", "Bid comparison"}, "Contract Administration (CA)", {"Payment approvals/bids", "Field notes/meeting minutes", "Pay applications", {"Incoming &amp; reviewed"}, "Change order requests", {"Log", "Reviewed", "Approved"}, "Submittals", {"Log", "Submittals", "Reviewed submittals"}, "Request for info (RFI)", {"Log", "RFI's", "RFI responses"}}, "Close-Out", {"Punchlist", "Warranties", "Lien releases", "Certificate of occupancy", "Meeting minutes", "Meeting agendas", "Finished form of presentation (PDF or PPT)"}, "Product Info", {"Cut sheets", "Installation manuals", "Instruction manuals", "CAD block of fixture"}, "Cost Data", {"Cost estimates", "Cost analysis", "Bill of materials", "RSMeans information", "General contractor proposals/bids", "Vendor bids"}, "Communication", {"Email correspondence (dated)", "Meeting minutes (# and date)", "Client", {"Incoming", "Outgoing"}, "Contractor", {"Incoming", "Outgoing"}, "Consultant", {"Incoming", "Outgoing"}}}
  
  set j_name to text returned of (display dialog "Enter Job Name:" default answer "job name")
  repeat
      try
          set j_number to text returned of (display dialog "Enter Job Number:" default answer "0")
          if (j_number as integer) &lt; 10000 and ¬
              (j_number as integer) &gt; -1 then exit repeat
      on error errMess number errNum
          if errNum is -128 then error errMess number errNum
          display alert "Error" message "Project Number is not a number or is out of range."
      end try
  end repeat
  set j_number to text -5 thru -1 of ("0000" &amp; j_number &amp; " ")
  set structure to {j_number &amp; j_name} &amp; {structure}
  makeFolderStructure out of structure at (choose folder with prompt "Choose parent folder for structure")
  
  
  to makeFolderStructure out of someItem at someFolder
  
    set currentParent to someFolder
    if class of someItem is not list then set someItem to {someItem}
    set completed to true
    repeat with anItem in someItem
      if class of anItem is list then
          makeFolderStructure out of anItem at currentParent
      else --  
          tell application "Finder" to try
              make new folder at someFolder with properties {name:(anItem as text)}
              set currentParent to result as alias
          on error errMess number errNum
              if errNum is -48 then
                  set currentParent to ((someFolder as text) &amp; (anItem as text)) as alias
              else
                  set completed to false
              end if
          end try
      end if
    end repeat
    return completed
  end makeFolderStructure
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/xwBke.jpg" rel="nofollow noreferrer">What happens when I run my Code</a></p>
  
  <p><a href="https://i.stack.imgur.com/93SN6.jpg" rel="nofollow noreferrer">What I would like to get when I run my code</a></p>