Re: Remove extra spaces from a string
Re: Remove extra spaces from a string
- Subject: Re: Remove extra spaces from a string
- From: "Marc K. Myers" <email@hidden>
- Date: Fri, 6 Jun 2003 13:53:07 -0400
Date: Fri, 06 Jun 2003 18:46:48 +0200
Subject: Remove extra spaces from a string
From: M=?ISO-8859-1?B?4XR54Q==?=s Ferenc Farkas <email@hidden>
To: <email@hidden>
The Anarhcy lists a content of an FTP server in a file, what looks like
this:
-rwx------ 0 286 512 Jun 06 12:36 demo10.log
-rwx------ 0 286 512 Jun 06 12:37 demo11.log
-rwx------ 0 286 512 Jun 06 12:38 demo12.log
-rwx------ 0 286 512 Jun 06 12:39 demo13.log
-rwx------ 0 286 512 Jun 06 12:40 demo14.log
I have to get the name of the file (last text item of... With a space
TID),
what works fine, and the creation date of the file. Between the first
three
columns there are multiple spaces. I get many "" strings, if I do a
repeat
loop with a space TID. How can I remove the extra spaces in AS or
Finder
from a string like this? I found a script for it in InDesign, but the
application keywords doesn't work anywhere else.
Try this:
set theText to "-rwx------ 0 286 512 Jun 06 12:36
demo10.log
-rwx------ 0 286 512 Jun 06 12:37 demo11.log
-rwx------ 0 286 512 Jun 06 12:38 demo12.log
-rwx------ 0 286 512 Jun 06 12:39 demo13.log
-rwx------ 0 286 512 Jun 06 12:40 demo14.log"
set oldCount to -1
set newCount to count theText
set od to AppleScript's text item delimiters -- save old delimiters
repeat until oldCount = newCount
set oldCount to newCount
set AppleScript's text item delimiters to " " -- two spaces
set theText to text items of theText
set AppleScript's text item delimiters to " " -- one space
set theText to theText as string
set newCount to count theText
end repeat
set AppleScript's text item delimiters to od -- old delimiters
log theText
Marc [06/06/03 1:51:37 PM]
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.