Help! :Create a file, but need to trim name first.

I created a killer script that sorts a huge collection of email scripts, saves and logs how many it found. In the process of creating a new file to save the emails it finds it creates it by the ending domian name.
Here in lies the problem. some domains are over 30 characters long. I need a way to trim the domain down to 30 characters only I however have not found any such example yet. Please tell me how to trim the total of a value or variable.
Any help would be appriciated!! Thanks, David.

Which part do you want to trim? The beginning…the end?
Rob

Um… Can you tell me both? If not, how to trim from the beginning would be wonderfull.
David

This might work:

set theDomain to "myveryverylonghotmaildomainname.com"
if (count of characters of theDomain) is greater than or equal to 30 then 
set trimmedDomain to text -30 thru end of theDomain -- last 30 
set trimmedDomain to text 1 thru 30 of theDomain -- first 30 
else 
set trimmedDomain to theDomain 
end if

Rob

Hey, I gotta say Thanks. The first one you gave me for an example worked great! I have finished the technical info for that script, and now am using dialog director to make it more user friendly (not that it needs it).
Once again, Thanks, Rob! Sincerely, David Coffey

: Hey, I gotta say Thanks. The first one you gave me for an example worked
: great! I have finished the technical info for that script, and now am
: using dialog director to make it more user friendly (not that it needs
: it).
: Once again, Thanks, Rob! Sincerely, David Coffey
Great! I hope that if the script is something that might be useful to others,
and it’s not proprietary, it finds its way to ScriptBuilders. :slight_smile:
Rob