Re: File name list help?
Re: File name list help?
- Subject: Re: File name list help?
- From: has <email@hidden>
- Date: Sun, 7 Oct 2001 14:07:11 +0100
T.J. Mahaffey wrote:
>
I'm working on a script which will make it easier to manipulate names of
>
files for pasting into emails or word processors.
>
>
What I have so far works like a champ, but I'd like to be able to insert a
>
common character after each item in the list. In it's current state, the
>
paste-able clipboard comes out like this: item1item2item3
>
>
I'd LIKE it to come out like this:
>
>
item1, item2, item3
>
>
OR with a return after each item
>
I'm convinced it'll have something to do with a repeat loop (?) and maybe a
>
"count of theList" command somewhere...?
Though you can do it with a loop, it's much simpler to use Applescript's
text item delimiters (TIDs). When you coerce a list of strings to text,
this value is used to separate each item. By default, AS's TIDs are set to
{""}, but you can set them to any character string you like - in your case:
", " or return.
HTH.
has
Here's the script (mind the wrap):
======================================================================
set yourDelimiter to ", "
set oldTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to yourDelimiter
tell application "Finder" to set theItemNames to name of every item
[NO-BREAK]in selection as text
set AppleScript's text item delimiters to oldTIDs
set the clipboard to theItemNames
======================================================================
[formatted using ScriptToEmail - gentle relief for mailing list pains]
[
http://files.macscripter.net/ScriptBuilders/ScriptTools/ScriptToEmail.hqx]