Ok, I’m working on making an automator workflow that would get the selected files into a message, then append the name of each file in the subject line.
I’ve looked into variables, but can’t seem to find anything that would take the name of those files. I’ve turned to applescript and this is what I have so far…
tell application “Finder”
set a_list to selection
repeat with i from 1 to number of items in a_list
set TheName to (name of item 1 of a_list)
end repeat
get TheName
–set the clipboard to TheName
end tell
The problem, is that it gives me only one name, and not a list of all those name separated with a coma. I’ve read about getting lists but I don’t get how to extract all items at once, it only gives me the last one that gets into the repeat loop.
This is so basic, I don’t understand how automator can’t do this basic stuff, (or can it?)
set a_list to selection
repeat with i from 1 to count of a_list
set TheName to (name of item i of a_list) as text
end repeat
get TheName
--set the clipboard to theName
end tell
and still get only ONE name, instead of the list I’m looking for, what am I doing wrong?
Stefan was right! but there was another problem. You set one variable over an over again instead of creating a list (or using an existing list as in my example below) and add/change the value by it’x index. So even when that is ready you can’t set it in the clipboard because you can’t set a list in there. In my example I use text item delimiters to create 1 string seperated by a comma
set theNames to nameKeyValue from selection of application "Finder" as list
set AppleScript's text item delimiters to ", "
set theNamesinPlainText to theNames as string
set AppleScript's text item delimiters to ""
set the clipboard to theNamesinPlainText
on nameKeyValue from thisList
repeat with x from 1 to count thisList
set item x of thisList to name of item x of thisList
end repeat
return thisList
end nameKeyValue
tell application "Finder"
set a_list to selection
set nameList to {}
repeat with i from 1 to count of a_list
set end of nameList to (get name of item i of a_list)
end repeat
end tell
set {TID, text item delimiters} to {text item delimiters, return}
set nameList to nameList as text
set text item delimiters to TID
--set the clipboard to theName