[Linux] Movie-folder-renamer (Bash + Perl)
Posted: January 21st, 2011, 11:27 pm
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
.
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
.