I have the need to change several hundred file names that are in the format of fname lname ∑ company name, where fname is a persons first name followed by a space, followed by a persons last name followed by a space and the ∑ symbol and then a space followed by a company name. They are all in this exact format. I would like them to be lname, fname ∑ company name. Is there a way to do this? Some sort of Folder Action, Automator script etc?
set theFolder to choose folder
tell application "Finder"
set theFiles to every file of folder theFolder
repeat with aFile in theFiles
set {name:n} to properties of aFile
set {fName, lName, sym, com, ext} to words of n
set newName to lName & " " & fName & " " & sym & " " & com & "." & ext
set name of aFile to newName
end repeat
end tell
Oh, and make a copy of your folder to test with first =)
Thank you so much. This just about did it. It’s my fault. I should have stated that the company name part of the file name could be more than one word…ie… ABC Company or ABC of Seattle. Also there are no file extentions, just standard text files.
set theFolder to choose folder
tell application "Finder"
set theFiles to every file of folder theFolder
repeat with aFile in theFiles
set {name:n} to properties of aFile
set {fName, lName, sym, com} to {item 1, item 2, item 3, items 4 through -1} of words of n
set comStr to ""
repeat with aWord in com
set comStr to comStr & " " & aWord
end repeat
set newName to lName & " " & fName & " " & sym & comStr
set name of aFile to newName
end repeat
end tell
Thank you, thank you , thank you. Worked perfect. You just saved me a ton of time. I wish there was some way to repay you for your help. Thank you again. P.S. Any recommendations for learning Applescript for a beginner?
This website has a lot tutorials. One of them is called “AppleScript Tutorial for Beginners”. I think there’s 8 articles for it. You can see them in the Unscripted section of the website at http://macscripter.net/unscripted.