Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Cattywampus_

macrumors 6502a
Original poster
Hi There

I need a way to quickly remove text from a load of file names. I have ripped my DVD TV show series to my Apple TV and transfered them, but I want to make all the file names simpler that what they are currently. Changing them all through FTP would take ages - so I am hoping there is some kind of recursive command I can use to eliminate a set bit of text from a group of folders.

Folder structures :

External HDD Root
|___TV Shows
|___TV Show 1
| |___Season1
| | |_______ TV Show Name - 1x01 - Episode Name.avi
| | |_______ TV Show Name - 1x02 - Episode Name.avi
| |___Season2
| |_______TV Show Name - 2x01 - Episode Name.avi
| |_______TV Show Name - 2x01 - Episode Name.avi

So the bit I want to remove is "TV Show Name - ". Just want to delete it from all the filenames.

Anyone help? 🙂

Thanks
 
I think you'd be better off with a really quick Automator workflow. If you need help / tips just ask 🙂
 
In Linux this works, but not sure in OS X. Can you try this in Terminal first? If it works, then I'll post the rest of the script.

Code:
find /path/to/shows -type f -name *.avi

It should return a listing of all avi files. If not, I'll find a workaround.
 
Sorry I forgot to say.

There is an External USB HDD connected to the ATV. I can only access it through FTP or SSH. I tried MacFusion to mount the drive in Finder, but it only mounts the internal HDD of the ATV. There is a Symbolic link but it won't actually navigate to the ext. drive.

So yeah - it really needs to be a shell script 🙂

Thanks.
 
Here's what I've come up with:
Code:
#
# Renames files from "TV Show Name - 2x01 - Episode Name.avi" to "2x01 - Episode Name.avi"

SHOWS_DIR="/path/to/shows"

for FILENAME in `find ${SHOWS_DIR} -type f -name *.avi`; do
	NEW_FILENAME="$(echo "$FILENAME" | cut -d- -f2-)"
	echo mv "${FILENAME}" "${NEW_FILENAME}"
done

You should place this into a file and run it. It will output the commands. If the commands look okay, then remove the "echo" part of that line.

This assumes the "TV Show Name" does not have any hyphens in it.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.