• 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
Enhance text parsing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Enhance text parsing


  • Subject: Enhance text parsing
  • From: KOENIG Yvan <email@hidden>
  • Date: Thu, 15 May 2008 12:45:36 +0200

Hello

Trying to help someone on MacScripter, I added some "classic AppleScript" instructions to a piece of code from Bruce Phillips.
The script must be used under 10.4.11 which returns datas organised in a way different of the one returned by 10.5.


The result is:

--[SCRIPT]
set someFolder to path to applications folder

set liste to do shell script "/usr/bin/mdfind -0 -onlyin " & ¬
	quoted form of POSIX path of someFolder & ¬
	" \"kMDItemContentTypeTree == 'com.apple.application*'\"" & ¬
	" | /usr/bin/xargs -0 " & ¬
	" /usr/bin/mdls -name kMDItemDisplayName -name kMDItemVersion" & ¬
	" | /usr/bin/grep '^kMD.*[^-]$'"

set liste to my remplace(liste, quote, "")
set liste to my remplace(liste, "kMDItemDisplayName = ", "")
set liste to my remplace(liste, return & "kMDItemVersion = ", tab & "<version> ")


set liste to paragraphs of liste
repeat with i from 1 to count of liste
if item i of liste does not contain tab then set item i of liste to (item i of liste) & tab & "<no version>"
end repeat


set AppleScript's text item delimiters to return
set liste to liste as text
set AppleScript's text item delimiters to ""
set the clipboard to liste

on remplace(t, d1, d2)
	set AppleScript's text item delimiters to d1
	set l to text items of t
	set AppleScript's text item delimiters to d2
	set t to l as text
	set AppleScript's text item delimiters to ""
	return t
end remplace
--[/SCRIPT]

Is there a way to enhance it with a bit of perl, ruby or other text dedicated tool?

For those which don't like this kind of treatment, I just add that as log as a piece of code starts with do shell script, it fit in this forum's status ;-)

No offense to Stockly, Ed.

Yvan KOENIG (from FRANCE jeudi 15 mai 2008 12:43:23)

While you try to help, I will listen to "Ruby my Dear" by Thelonious Monk.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users


This email sent to email@hidden
  • Prev by Date: photoshop estimated document sizes
  • Next by Date: Rép: Enhance text parsing
  • Previous by thread: photoshop estimated document sizes
  • Next by thread: Rép: Enhance text parsing
  • Index(es):
    • Date
    • Thread