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

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

Hi,

it’s just

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

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