Applescript: display the input filename in a notification

Hi, I'm trying to display the input filename in a notification using Automator. Here is my Applescript:


on run {input, parameters}
	
	display notification input with title "Action done" subtitle "Completed"
	
	return input
end run


Is there a way to display the filename/basename of input?


Thanks

Posted on Jun 9, 2022 1:51 AM

Reply
4 replies

Jun 9, 2022 5:18 AM in response to friendlygiraffe

The syntax for display notification can be found here. The following syntax tests correctly in macOS 11.6.6 with Automator:


use scripting additions

on run {input, parameters}
	
	tell application "Finder" to set basename to name of (input as alias) as text
	display notification basename with title "Action done" subtitle "Completed"

	return input
end run

Output looks like this:


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.

Applescript: display the input filename in a notification

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