Script to Rename Selected File

I have found this script and I would like to modify it to do what I expect it to do:

tell application "Finder"
	set theFile to (choose file)
	set name of theFile to "artwork.png"
end tell

So here’s what I need:
1 - I would like to create a Service out of this script so I can just access it when I right click the file
2 - I would like the script to be applied to the selected file, instead of asking me which file I want to rename.

Can someone please help me with this?
Thanks :slight_smile:

AppleScript: 2.11
Browser: Safari 605.1.15
Operating System: macOS 10.15

The following works in Monterey and appears to work in Catalina:

  1. Open the Automator app and select File > New then Quick Action.

  2. At the upper-right corner after the heading “Workflow receives current”, select from the drop-down list “files and folders”. Then, after the heading “in”, select from the drop-down list “Finder.app”.

  3. From the left pane, select and drag “Run AppleScript” to the right pane. Paste the script contained below into the right pane replacing all existing text. Double-check the contents of the script because Automator’s auto-complete may add unwanted text.

  4. Save the Quick Action with whatever name is desired and quit Automator.

  5. In a Finder window, select and right-click on a file. Scroll down the context menu to Quick Action and select the Quick Action script saved in 4 above. This should rename the selected file. The Quick Action script will also appear in the Finder > Services.

The script that I tested was:

on run {input}
   tell application "Finder"
      set name of (item 1 of input) to "artwork.png"
   end tell
end run
1 Like

Right click the file in the Finder, click Rename menu item, type artwork.png.
You ask for service which already exists, it is preinstalled.

Or, click on the name of file in the Finder, edit it.

Also, you can copy “artwork.png” to the clipboard, click file names one by one and paste…