Get multiple file names and feed them into variable

I have an automator app partly containing a "Run AppleScript" section where I want to feed filenames from the input into a variable that I later use as a title for in an email generated by the workflow in the app with "New Mail Message".


Here's the apple script code:

on run {input, parameters}
	
	tell application "Finder"
		set Filenames to name of file input
	end tell
end run



When i input one file everything runs smoothly, but if i input two or more i get this error message "Can't make ___ into type integer" :


I'm on 10.15.7 Catalina with a 16" MBP (2019)

MacBook Pro 16″

Posted on Feb 8, 2023 05:54 AM

Reply
Question marked as Top-ranking reply

Posted on Feb 8, 2023 06:42 AM

Use the following:


tell application "Finder"

set Filenames to ""

repeat with this_file in input

set Filenames to Filenames & name of this_file & return

end repeat

set Filenames to items 1 thru -2 of Filenames as string

end tell


(234236)

Similar questions

4 replies

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Get multiple file names and feed them into variable

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.