La forma nativa de Applescript para renombrar archivos es:
tell application "Finder"
set theFile to (choose file)
set name of theFile to "Yay"
end tell
Si quieres renombrar todos los archivos de una carpeta, pondría los archivos en una lista y usaría un Repeat
bloque en cada uno de ellos:
tell application "Finder"
set theFolder to (choose folder)
set folderContents to every item of theFolder
repeat with theFile in folderContents
set name of theFile to "Yay"
end repeat
end tell
(Este código no funcionará del todo porque no puedes tener dos archivos con el nombre "Yay", pero el primero sí se renombra, y ya te haces una idea).
Esto se acerca más a lo que quieres hacer, pero no estamos del todo ahí: quieres obtener el nombre del archivo actual, hacer algunos cambios en él y guardar el nuevo nombre.
Hay una subrutina que encontré hace años en alguna parte (ahora no encuentro la fuente) que obtendrá todo lo que esté a la derecha de un determinado carácter, como un guión bajo. Esto hace que sea fácil hacer exactamente lo que quieres. El código completo y final es:
tell application "Finder"
set theFolder to (choose folder)
set folderContents to every item of theFolder
repeat with theFile in folderContents
set oldName to name of theFile
set newName to my rightString(oldName, "_")
set name of theFile to newName
end repeat
end tell
on rightString(str, del)
local str, del, oldTIDs
set oldTIDs to AppleScript's text item delimiters
try
set str to str as string
if str does not contain del then return str
set AppleScript's text item delimiters to del
set str to str's text items 2 thru -1 as string
set AppleScript's text item delimiters to oldTIDs
return str
on error eMsg number eNum
set AppleScript's text item delimiters to oldTIDs
error "Can't rightString: " & eMsg number eNum
end try
end rightString