Sorry, I am useless when it comes to this stuff but I have tens of thousands of images (.eps. .jpg, .tif, etc.) all of which need file extensions added. I searched the archives and found that many people have asked this question and plenty have answered but nothing I tried worked for me. Maybe it is because the answers assume a certain level of knowledge? In any case, can someone help me with this? I would like it to be able to ask me to locate the folder with the files and then chug through and add the file extensions. Please!
tell application "Finder"
activate
set theSelection to choose folder with prompt "Select the folder containing the items you wish to rename."
set theSelection to every file of theSelection
set nameExtension to my getUserResponse("Enter extension name only, ex. pdf, not .pdf", {"Cancel", "Ok"}, "pdf")
repeat with i from 1 to count the theSelection
set thisItem to item i of theSelection as alias
set currentName to name of thisItem
set newName to currentName & "." & nameExtension as Unicode text
set name of thisItem to newName
end repeat
end tell
on getUserResponse(theMessage, buttonList, theName)
activate
set userResponse to (display dialog theMessage default answer theName buttons buttonList default button 2)
set fileName to text returned of userResponse
set theButton to button returned of userResponse
if theButton = "Cancel" then error -128
return fileName
end getUserResponse
Thanks very much – that worked beautifully! But… in a perfect world I would like the script/Mac to be able to figure out what the file extension should be without me having to tell it. Is that possible? If not I know I can just sort by file type and do folders full of like files instead of all at once. That’s certainly easy enough. Thanks again.
Run this script on several files and tell me the results you get.
I want to make sure you are getting extension names.
tell application "Finder"
set chooseFile to choose file without invisibles
set nameExtension to name extension of chooseFile
display dialog nameExtension
end tell