I’m writing a script to build job folders that use a specific naming convention:
I need a little help on using certain characters in a user response to name my folders.
ie. user gives job number of 2XXX_XXXX_XXXXX
this is the name of the first job folder, inside of this will be created 6 folders named for seperate types of files, and I need to use the last 5 numbers of the user response as a prefix to these folders
I’m sure this is an easy one, but I can’t seem to figure it out…any help please!
Something like this might get you started. It should include routines to verify the data entered in the dialog by the user.
set destination_ to choose folder with prompt "Choose a destination for the job folder."
set dd to (display dialog "Enter a job number." default answer "2XXX_XXXX_12345")
set prefix_ to text -5 thru end of text returned of dd
set subfolder_names to {"gif", "jpeg", "txt", "pdf", "html", "ps"}
tell application "Finder"
try
set nf to make new folder at destination_ with properties {name:text returned of dd}
repeat with name_ in subfolder_names
make new folder at nf with properties {name:prefix_ & "_" & name_}
end repeat
on error e
display dialog e
end try
end tell