Monday, July 24, 2017

#1 2017-03-19 02:43:09 pm

CAPTURE-A
Member
From:: Brooklyn
Registered: 2017-01-15
Posts: 4

Retooling a folder making script

Hello!

I’m looking to finesse a script I have and am looking for some help.

Basically I would like to have the number sequence come before the name….and if possible…have a leading zero for numbers 1-9 (example 01_New_Folder). Currently the script generates the following naming - New_Folder_1.
I would never exceed creating more than 99 folders so I’m only interested in creating a 2 digit number prefix.

My basic AppleScripting skills are proving this task to be difficult for me.

Any guidance would be helpful!

-Aaron

Applescript:

set folderMaker to text returned of (display dialog "Please enter root folder name:" default answer "Folder Maker")
set loc to (choose folder "Choose Parent Folder Location" default location (path to desktop folder) as alias)

tell application "Finder"
   set newFolder to make new folder at loc with properties {name:folderMaker}
end tell
repeat
   
   
   set subCount to text returned of (display dialog "How many folders?" default answer 10)
   try
       if subCount ≠ "" then
           subCount as integer
           exit repeat
       end if
   end try
end repeat

set folderName to text returned of (display dialog "Please enter sub folder base name:" default answer "New_Folder")

repeat with i from 1 to subCount
   tell application "Finder" to make new folder at newFolder with properties {name:folderName & "_" & i}
end repeat


Filed under: folders

Offline

 

#2 2017-03-19 02:55:43 pm

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11453
Website

Re: Retooling a folder making script

Hi,

it's just

Applescript:

set folderName to text returned of (display dialog "Please enter sub folder base name:" default answer "New_Folder")

repeat with i from 1 to subCount
   set folderNumber to text -2 thru -1 of ("0" & i) -- creates the leading zero if I < 10
   tell application "Finder" to make new folder at newFolder with properties {name:folderNumber & "_" & folderName}
end repeat

Last edited by StefanK (2017-03-19 02:55:58 pm)


regards

Stefan

Offline

 

#3 2017-03-19 04:26:21 pm

CAPTURE-A
Member
From:: Brooklyn
Registered: 2017-01-15
Posts: 4

Re: Retooling a folder making script

Stefan!

This is the 2nd time you stepped in to help me out! Your help is very much appreciated!

The script runs perfectly!

Thanks again Stefan!!!!

Cheers,

-Aaron

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)