Clean up poorly named TV shows.

rename -v 's/.*[s,S](\d{2}).*[e,E](\d{2}).*\.avi/SHOWNAME\ S$1E$2.avi/' poorly.named.file.s01e01.avi
Replace 'SHOWNAME' with the name of the TV show. Add -n to test the command without renaming files. Check the 'sample output'.
Sample Output
rename -v 's/.*[s,S](\d{2}).*[e,E](\d{2}).*\.avi/Dexter\ S$1E$2.avi/' *.avi   renamed as    Dexter S01E01.avi
S01E02 Dexter dvdrip.avi          renamed as    Dexter S01E02.avi
dexter.s01-e03.proper.avi         renamed as    Dexter S01E03.avi
Dexter.S01E04.HDTV.XviD-NoTV.avi  renamed as    Dexter S01E04.avi

By: Karakh
2009-09-29 16:39:57

What Others Think

This is actually pretty nice :) Good job. It's simple, too (for those who know Perl-style regular expressions, at least)
kaedenn · 629 weeks and 3 days ago
Wow, it just took me 10 minutes to reorganize my 2tb media sever by using 'find' and this command. Thanks buddy.
youboreme · 629 weeks and 3 days ago
There is a strong message that lies in this post that is conveyed so effectively.I would recommend my online team to follow this post for better performance.Good to see this post and continue sharing more posts.Thank you very much.
FrankSullivan · 74 weeks and 1 day ago
This is the first time I read this kind of article and it is very useful for students. In this article, the author shares a program related to the rename function. From this article, you can understand the purposes of this function.
jennifer247 · 68 weeks ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: