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

The only thing I’d suggest, which may not match your needs or intentions, is to trim the file name from the middle. This has the advantage of keeping the beginning of the filename intact (for, say, sorting purposes and some meaning) while keeping the extension intact (important in OS X).

So the change to your script would look like this:

set theDomain to ""

if (count of characters of theDomain) is greater than or equal to 30 then
	set firstPart to text 1 thru 15 of theDomain
	set secondPart to text -14 thru end of theDomain
	set trimmedDomain to firstPart & "…" & secondPart
	-- the character in the quotes is an option-semicolon, the ellipses
	set trimmedDomain to theDomain
end if

Not sure if this is useful, but I thought I’d mention it.