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

dexter.s01e01.hdtv.xvid.lol.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

18
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 · 606 weeks and 1 day ago
Wow, it just took me 10 minutes to reorganize my 2tb media sever by using 'find' and this command. Thanks buddy.
youboreme · 606 weeks and 1 day ago
There is a strong message that lies in this post that is conveyed so effectively.I would recommend my https://assignmentjunkie.co.uk/do-my-dissertation-for-me online team to follow this post for better performance.Good to see this post and continue sharing more posts.Thank you very much.
FrankSullivan · 50 weeks and 6 days 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. https://www.iheartcbdoil.com/cbd-reviews/which-are-the-aspects-to-be-contemplated-on-before-devouring-cbd/
jennifer247 · 44 weeks and 5 days 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?

commandlinefu.com 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.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

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: