Context
As most people, I often complain about not having sufficient time. It also doesn’t help that I have a lot of hobbies and interests. Because of this I decided to combine my hobbies and interests in such a way it would eventually save me time.
Basically I decided to learn powershell scripting by automating the task of renaming downloaded movies. These need to be in a specific format for reliable use with the movie jukebox called Yet Another Movie Jukebox (YAMJ). As a result this will save me a lot of time in the future.
Concept for the script
The file names of most movies I download are mostly in the following format:
The.Devils.Advocate.1997.UNRATED.DC.720p.BluRay.X264-AMIABLE.mkv
<movie.name>.<movie release year>.<metadata>.<metadata>…..<last.metadata>.<file extension>
What is important for YAMJ to work correctly is basically the movie name and the year (just in case there are movies with the same name, but released in a different year). So basically my preferred output would be:
The Devils Advocate 1997.mkv
To realise this, conceptually the following will be done for all files in a specific folder:
- Determine the current file extension and save it to a variable.
- Remove all dots “.” from the file name.
- Determine if there is a year notation in the file name (by example 1997).
- If there is no year notation found, don’t do anything else (file does not meet the expected format).
- If the year notation is found, remove everything from the file name after the year notation and re-add the file extension.
The script itself
The script itself can be found on my sharepoint list :
http://bjornhouben-web.sharepoint.com/Lists/Scripts/
Closing thoughts
I hope this will help home users to see the advantages of scripts, use them and benefit from it. For ICT professionals I also hope that it will help them get a better understanding of Powershell. Because in my opinion Powershell is getting increasingly important both for Microsoft and non Microsoft products (by example VMware).
I’d love to get feedback about this post and hope to receive some replies.