zs2020
zs2020

Reputation: 54541

How to set the file in rename mode in apple script?

I know this question is a little bit crazy, but I do want to know the solution. Is there any way to run an apple script to set any given file or folder in rename mode so that the user can type in the new name? I know I can do the rename easily in script but I am just wondering whether it is doable or not.

Thanks in advance!

Upvotes: 0

Views: 202

Answers (2)

Michael J. Barber
Michael J. Barber

Reputation: 25052

It is possible using UI scripting. First select whichever item you're interested in---presumably through AppleScript in practice, but by hand is fine for trying it out. Then:

tell application "Finder" to activate
tell application "System Events" to keystroke return

Upvotes: 1

Flambino
Flambino

Reputation: 18793

Well, you can sort of hack it together with System Events

tell application "Finder"
    activate
    select file "test.png" of desktop
    tell application "System Events" to keystroke return
end tell

It's kind of a hack, though, but I don't know if there's another way to do it

Upvotes: 2

Related Questions