Berikut ini adalah solusi AppleScript yang cukup efisien. Anda dapat menyimpan kode ini di script editor.app sebagai aplikasi.
set newName to 0
set theFolder to (choose folder with prompt "Choose Folder" with invisibles)
tell application "Finder"
set theFolders to folders of theFolder
set sortedFolders to sort theFolders by name
repeat with i from 1 to count of sortedFolders
set newName to newName + 1
set thisItem to item i of sortedFolders
set name of thisItem to newName
end repeat
end tell
Jika Anda lebih suka nama folder satu digit muncul sebagai dua digit (01,02,03 dll.), Gunakan versi skrip berikut ini sebagai gantinya
set newName to 0
set theFolder to (choose folder with prompt "Choose Folder" with invisibles)
tell application "Finder"
set theFolders to folders of theFolder
set sortedFolders to sort theFolders by name
repeat with i from 1 to count of sortedFolders
set newName to newName + 1
set thisItem to item i of sortedFolders
if newName is less than 10 then
set name of thisItem to 0 & newName as string
else
set name of thisItem to newName
end if
end repeat
end tell
Kode AppleScript berikut ini akan mengganti nama file dalam folder yang dipilih, daripada mengganti nama folder.
set newName to 0
set theFolder to (choose folder with prompt "Choose Folder" with invisibles)
tell application "Finder"
set theFiles to files of theFolder
set sortedFiles to sort theFiles by name
repeat with i from 1 to count of sortedFiles
set newName to newName + 1
set thisItem to item i of sortedFiles
set nameExtension to name extension of thisItem
if newName is less than 10 then
set name of thisItem to 0 & newName & "." & nameExtension as string
else
set name of thisItem to newName & "." & nameExtension as string
end if
end repeat
end tell