local renameFile = function(num) local success, res, desc = hs.osascript.applescript( [[ set num to "]] .. num .. [[" -- tell application "Finder" set theFiles to (get selection) repeat with i from 1 to count of theFiles set thisFile to item i of theFiles set thisName to name of thisFile set theOffset to my (offset of "." in thisName) if theOffset < 4 then set orgName to text (theOffset + 1) thru -1 of thisName set newName to num & "." & orgName if num = "10" then set newName to orgName end if set name of thisFile to newName end if end repeat end tell]]) -- print(success, res, desc) hs.eventtap.keyStroke(nil, 'escape') end
key bind
F5 ~ F10 키를 바인딩 한다. F10 은 원래로 돌아오는 용도다.
1 2 3
for _, n inipairs({ 5, 6, 7, 8, 9, 10 }) do hs.hotkey.bind(nil, "F" .. n, rename(n)) end