Tuesday, July 14, 2020

#1 2002-04-30 06:35:42 am

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

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.


One mans trash is another mans treasure

Offline

 

#2 2002-04-30 06:40:09 am

Rob
Member
From:: Ohio, USA
Registered: 2002-11-20
Posts: 1886

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

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

Offline

 

#3 2002-04-30 07:23:05 am

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

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

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


One mans trash is another mans treasure

Offline

 

#4 2002-04-30 07:35:07 am

Rob
Member
From:: Ohio, USA
Registered: 2002-11-20
Posts: 1886

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

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


This might work:

Applescript:

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

Offline

 

#5 2002-04-30 09:03:36 am

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

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

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


One mans trash is another mans treasure

Offline

 

#6 2002-04-30 09:25:55 am

Rob
Member
From:: Ohio, USA
Registered: 2002-11-20
Posts: 1886

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

: 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. :-)
Rob

Offline

 

#7 2002-04-30 12:01:54 am

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

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

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).

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:

Applescript:

set theDomain to "myveryverylonghotmaildomainname.com"

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
else
   set trimmedDomain to theDomain
end if

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


One mans trash is another mans treasure

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)