Need help renaming files - Switch the beginning with the end

I’ve tried all kinds of batch renaming utilities including the “Name those Files!” app, and none seem to be able to do exactly what I want, so I was hoping one of the AS geniuses here could help me.

What I have are a bunch of Music Videos from the iTMS in a folder. They’re named in the format of “Song Name - Artist.mov”. I’d like to change them to “Artist - Song Name.mov” so it’s easier to find videos by the same artist.

There are 38 movies there, so if it came down to it I could do it myself (as opposed to people I’ve seen needing to rename thousands of files), but I’m sure there’s a script that could do the job for me.

Ideas?

Assuming that the files are named using your simple “Song Name - Artist.mov” convention, the following should work. As you said, for large-scale renaming it’s probably not the best… but for a few dozen files, it’ll do the job.

set theFolder to (choose folder without invisibles)
set theFolderList to (list folder theFolder without invisibles)

repeat with tmpFile in theFolderList
	if tmpFile ends with ".mov" then
		set tmpFilePath to (theFolder & tmpFile) as string
		set tmpName to text 1 through -5 of (tmpFile as string)
		try
			set AppleScript's text item delimiters to " - "
			set {tmp1, tmp2} to text items of tmpName
			set newName to ((tmp2 & " - " & tmp1 & ".mov") as string)
			tell application "Finder"
				set name of (file tmpFilePath) to newName
			end tell
		end try
		set AppleScript's text item delimiters to ""
	end if
end repeat

j

That script worked like a charm. Thanks!

While I’m glad you found a script to do what you want, you could easily do this in Name those Files! by using a GREP search and replace. Just set the search type to GREP and search for:

(.)( - )(.)

and replace with:

321

That’s it.

Jon

Jon,

I don’t think you need 3 patterns there

I think this would work
(.) - (.)
replace with
2 - 1

just checking my grep knowledge here;-)

Lesta