• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Remove extra spaces from a string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Remove extra spaces from a string


  • Subject: Re: Remove extra spaces from a string
  • From: Peter Fischer <email@hidden>
  • Date: Fri, 6 Jun 2003 19:51:15 +0200

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.

This works for me:

set myText 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 paragraphList to every paragraph of myText

set newText to ""
set NameList to {}

set AppleScript's text item delimiters to " "
repeat with onePar in paragraphList
set FileName to last text item of onePar
set Date_Time to text items -4 thru -2 of onePar
set newName to FileName & " - " & Date_Time
set the end of NameList to newName
end repeat
set AppleScript's text item delimiters to "
" -- return
set newText to NameList as string
set AppleScript's text item delimiters to ""
return newText


Of course, within the repeat loop, you can combine the newName o whatever you want.

Regards
Peter
--
Peter Fischer aka Snow
Fischer-Bayern
"The source for german AppleScripters"
http://www.fischer-bayern.de
_______________________________________________
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.

  • Follow-Ups:
    • Re: Remove extra spaces from a string
      • From: Emmanuel <email@hidden>
References: 
 >Remove extra spaces from a string (From: Mátyás Ferenc Farkas <email@hidden>)

  • Prev by Date: Re: Remove Menu extras
  • Next by Date: Re: Remove extra spaces from a string
  • Previous by thread: Remove extra spaces from a string
  • Next by thread: Re: Remove extra spaces from a string
  • Index(es):
    • Date
    • Thread