S
S
SergDrakus2017-02-16 16:13:03
Programming
SergDrakus, 2017-02-16 16:13:03

How to implement file renaming with AppleScript in macOS?

Good day to all!
With the help of AppleScript and Automator, I want to create a service with which it will be possible to rename several files at once according to the algorithm I need. So, for example, by selecting 5 files on the desktop and pressing the keyboard shortcut (Command + 8), the files should get the same name and numbering from 1 to N.
How should this look in practice?
I select files, press a certain key combination, after which the file names are changed to the text that is on the clipboard (clipboard). At the same time, after this text, a space and a number should be placed, numbered from 1 or 0 (not important).
Here is the code that allows you to change the name for only one file and without numbering. How can it be improved?

tell application "Finder"
set name of (selection as alias) to (the clipboard)
end tell

--
Thank you all for your help!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya Brazhnikov, 2017-02-25
@Ilyabr

You can make it easier in Automator. There is a method Files and Folders - Rename Finder Objects.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question