Re: do shell script "sort" not working
Re: do shell script "sort" not working
- Subject: Re: do shell script "sort" not working
- From: Martin Orpen <email@hidden>
- Date: Tue, 08 Nov 2005 23:43:35 +0000
- Thread-topic: do shell script "sort" not working
on 8/11/05 20:12, Chris Tangora at email@hidden wrote:
> set sort_script to ("sort -o " & Imagessorted_POSIX & " " & ImagesUsed_POSIX)
> do shell script sort_script
If you've got serious amounts of data from which you need to remove
duplicates then you might be better off using a more powerful tool like awk.
I posted a script that does this kind of thing a some time ago. Search the
archives for my name and "awk" & "seen" - I'd do it myself, but my web
access is crap at the moment :(
Another option might be using objective-c and nsarray's *distinct* method:
<http://www.idea-digital.com/applescript/objc/page24/nsarray.html>
Which works wonders with numbers, but needs a little of help to sort
strings:
set theList to {}
repeat 100 times
set myletters to "abc"
set tempList to {}
repeat 4 times
set end of tempList to some item of myletters
end repeat
set end of theList to tempList as string
end repeat
set foo to procArray(theList)
set AppleScript's text item delimiters to ASCII character 10
set bar to do shell script "echo " & quoted form of (foo as string) & " |
sort"
set AppleScript's text item delimiters to {""}
(count of foo) & return & bar
on procArray(myArray)
tell application "Automator"
set theArray to call method "arrayWithArray:" of class "NSArray"
with parameter myArray
set sArray to call method "distinct" of myArray
end tell
end procArray
I don't know if it is supposed to be used in this way as I only discovered
it by tinkering. But it seems to get the job done whenever I call it.
Regards
--
Martin Orpen
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden