Re: Text items
Re: Text items
- Subject: Re: Text items
- From: kai <email@hidden>
- Date: Tue, 16 Jan 2007 22:17:08 +0000
On 16 Jan 2007, at 21:50, some muddlehead wrote:
Naturally, this doubles up on the iterations - so, for the examples
given, the script would loop 4 times: 2 (name ends) * 2 (extensions).
Actually, I missed a trick there. This loops only twice, to strip the
2 extensions - and then finishes off by trimming any "_M" endings:
-------------------
to strip_extensions from l to e
set tid to text item delimiters
set text item delimiters to return
set l to l as Unicode text
repeat
set text item delimiters to "."
if (count l's text items) is 1 then exit repeat
set text item delimiters to "." & paragraph 1 of l's text item -1
set l to l's text items
set text item delimiters to ""
set l to l as Unicode text
end repeat
set text item delimiters to e & return
set l to l's text items
set text item delimiters to return
set l to l as Unicode text
set text item delimiters to tid
l's paragraphs
end strip_extensions
set names1 to {"231-001_M.tif", "231-001.tif", "231-001.jpg",
"231-001-a_M.tif", "231-001-a.tif", "231-001-a.jpg"}
set names1 to strip_extensions from names1 to "_M"
--> {"231-001", "231-001", "231-001", "231-001-a", "231-001-a",
"231-001-a"}
-------------------
---
kai
_______________________________________________
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/mailman//archives/applescript-users
This email sent to email@hidden