Batch change file names?

Hello,

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?

Thank you so much in advance,
Vic

Give this a try

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.

Thank you again, I really do appreciate it.
Vic

Give this a try

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

It’s also worth taking a look at this script:

/Library/Scripts/Finder Scripts/Replace Text in Item Names.scpt

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?

Vic

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.

Apple also has a guide on the web at http://developer.apple.com/documentation/AppleScript/Conceptual/AppleScriptLangGuide/index.html

Plus you have lots of scripts on your computer already that you can look through to learn more. Apple provides them in /Library/Scripts.

Thank you for the links. I will check them out. I appreciate the help.

Vic