Page 1 of 1

[Linux] Movie-folder-renamer (Bash + Perl)

Posted: January 21st, 2011, 11:27 pm
by jocke
Hi,

This isn't really a post-process script, but I thought I'd share it anyhow.

I recently started using CouchPotato together with SABnzbd. When it has downloaded a movie, I've set it to move it + rename it as well, using the following naming-convetion;

()

Previously I used to just keep the original folder-name, and this became a mess -- it was, amongst other things, difficult to see if I had duplicates, and all movies starting with "The" was at the same place when sorting.

I then wanted to rename all the "old" folder-names using the same naming-convetion as CouchPotato, so I wrote a quick movie-rename-script in Bash and Perl. Nothing super-fancy, and it could be improved in probably a million places, but it did what I wanted at the time, so I thought I'd share it.

Basically it splits all the movies in two; those who already contain the release-year in the folder-name, and those who don't. This means that if you don't have the release-year in the folder-name, the new folder-name will just be "", without any "()". I could probably parse this from an IMDB-crawl or whatever, but I never bothered (I mostly use movie-software that pulls this information anyways).

So, to summarize the steps of the scripts;
- Gather a list of all folders from specified folder
- Find out what folders has a release-year, and those that doesn't
- Process the two separately
- Remove unwanted stuff from the folder-name
- Capitalize first character in all words except the first, and all words like "the", "of", "for", etc...
- If movie-name starts with "The", move it to the end; "The Transporter" becomes "Transporter, The"
- Move it
- Done

An example-folder;
/path/to/movies/The.Lord.Of.The.Rings.The.Return.Of.The.King.2003.1080p.BluRay.DTS.x264.PROPER-SOMEGRP
will be moved/renamed to;
/path/to/movies/Lord of the Rings the Return of the King, The (2003)


If something doesn't work, feel free to report it, and I'll see if I'll bother to fix it :-P

Lastest version of the script is available here; http://git.jocke.no/rename-movie-folder ... folders.sh

.

Re: [Linux] Movie-folder-renamer (Bash + Perl)

Posted: April 29th, 2012, 4:26 pm
by wreckedred
Hey - I so want this to work but it didn't....says it did but nothing actually got renamed


drew@htpc:~/scripts/prod$ ./doclean.sh
/home/drew/Videos/New/Match.Of.The.Day.2012.04.28.480p.HDTV.x264-mSD -> /home/drew/Videos/New/Match of the Day (2012)
Number of folders that was moved: 1


drew@htpc:~/Videos/New$ ls
Match.Of.The.Day.2012.04.28.480p.HDTV.x264-mSD

Re: [Linux] Movie-folder-renamer (Bash + Perl)

Posted: May 1st, 2012, 1:11 am
by J03 8LACK
wreckedred,

If you trying to match CouchPotato naming convention

Why not use CouchPotato to do the work for you.

Point CouchPotato's Download folder (Renaming Tab)to the folder of all your movies. ( or make a samller folder to test )

Then Point CouchPotato's Movie destination to a new folder ( not the same as above ) and watch.

CouchPotato is set to look in the download folder and processes all files and renames them and moves them to the new folder.



Jocke great script.
I like to look at the different ways others code and the more I look, the more ways I find to use them.

Give it a try.
J03