I am looking to be able to drop files into a folder and have them renamed “001.jpg” “002.jpg”, etc.
I tried looking at Automator, but that doesn’t seem to do the job I need, I’m thinknig AppleScript is more the right approach.
I found this script doing a search, which would work, but after the first file it doesn’t work again. I don’t really know much about AppleScript, although it reminds me of doing BASIC back when I was a kid.
Thanks for all your help and advice in advance!
on adding folder items to this_folder after receiving thoose_files
set defaultname to “MyName_” – the name you want to give to your files
set leadingZeros to 3 – the size of the argument of the file
tell application “Finder”
try
set z to count (files in thoose_files whose name contains defaultname)
on error
set z to 0
end try
try --count the number of files in the folder with the default name
set y to count (files in this_folder whose name contains defaultname)
on error
set y to 0
end try
repeat with x from 1 to count thoose_files
set argumentnumber to (x + y - z - 1) as string -- create the correct argument
tell application "Finder"
repeat until (count (argumentnumber)) > leadingZeros - 1
set argumentnumber to "0" & argumentnumber
end repeat
end tell
set name of item x of thoose_files to defaultname & argumentnumber --change the name
end repeat
end tell
end adding folder items to