Thank you both for your help.
I am playing about with your script at the moment because I understand it more.
How would I go about putting your code within an if statement i.e.
tell application "Finder"
if ProjectsFolder = "Projects" then
--Prompt to Choose a Client Name
set ProjectNamePrompt to text returned of (display dialog "Please enter your project's business name:" default answer "" buttons {"Cancel", "Create"} default button "Create")
set BaseName to cleanText(ProjectNamePrompt)
if BaseName contains "the" then
display dialog "The folder name will contain the letters " & quote & "the" & quote buttons {"Cancel", "Continue"} default button 2 with icon caution
end if
set i to 1
repeat 99 times
set NewName to BaseName & (text -2 thru -1 of ("0" & i))
try
alias ((CurrentDir as text) & NewName)
set i to i + 1
on error
tell application "Finder" to make new folder at CurrentDir with properties {name:NewName}
exit repeat
end try
end repeat
on cleanText(theText)
set lowerCase to "abcdefghijklmnopqrstuvwxyz"
set upperCase to "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
set theNumbers to "1234567890"
set cleanedText to {}
set characterCount to 0
repeat with aCharacter in theText
set aCharacter to contents of aCharacter
if aCharacter is in theNumbers then
set end of cleanedText to aCharacter
set characterCount to characterCount + 1
else if aCharacter is in lowerCase then
set end of cleanedText to (item (offset of aCharacter in lowerCase) of upperCase)
set characterCount to characterCount + 1
end if
if characterCount = 4 then return (cleanedText as text)
end repeat
display dialog "The project name does not contain four usable characters." buttons {"OK"} cancel button 1 default button 1 with icon stop
end cleanText
else
display dialog "Open your Clients 'Projects' folder first" buttons {"OK"} default button "OK" with icon caution --or use icon stop
end if
end tell
I get the following error when I try to save the script
Expected “else”, etc. but found “on”.