I’d use [shameless plug] Name those Files! You can use GREP replacements so you can set it to just use the original name with a GREP search & replace. Search for
Wow. As a guy who’s still more “classic” than “OS X”, these kinds of long filenames still throw me.
You got a nice, natural delimiter in there: space & hyphen & space, so let’s play with that:
set aviFolder to choose folder
set astids to AppleScript's text item delimiters -- save
try
set AppleScript's text item delimiters to " - "
tell application "Finder"
set aviFiles to every file of aviFolder whose name ends with ".avi"
repeat with aviFile in aviFiles
set nameParts to every text item of (get name of aviFile)
-- The 2-item shuffle, as they say...
--
set temp to item 2 of nameParts
set item 2 of nameParts to item 3 of nameParts
set item 3 of nameParts to temp
set name of aviFile to nameParts as string
end repeat
end tell
on error m number n from f to t partial result p
set AppleScript's text item delimiters to astids -- restore
error m number n from f to t partial result p
end try
set AppleScript's text item delimiters to astids -- restore
I already downloaded you script and tried to figure out the proper search pattern, but without no luck. Unfortunately the search pattern that you provided does dot work either.
AdmiralNovia,
Your script works fluently. Thanks!
Here is another working solution (a bit slower than AdmiralNovia’s) from other forum for those who are interested:
on open theseFiles
tell application "Finder"
set {tid, my text item delimiters} to {my text item delimiters, " - "}
repeat with theFile in theseFiles
set fileName to the name of theFile
set thePerformers to text item 1 of fileName
set theEvent to text item 2 of fileName
set theYear to (text item 3 of fileName) as string
set theRest to text items 4 thru (count of text items of fileName) of fileName as string
set newName to {thePerformers, theYear, theEvent, theRest}
set name of theFile to newName as string
end repeat
set my text item delimiters to tid
end tell
end open