How-to: Use batch files to organise recorded TV automatically

Windows ExplorerWhen I built my Windows Media Center PC, I was able to have the majority of features working as I wanted them to. This was using Windows Media Center 7, and a bunch of free applications working together. The only thing I could not get my HTPC to perform was to separate my recorded movies from the recorded TV. I then needed to put each of the files in a relevant folder so that Media Center Master would download the correct meta data. I performed this task manually for a while but knew there had to be a way to automate this process.

After a weekend of research and testing, I finally came up with the 50 lines of script that complete the media centres autonomy. This has effectively eliminated the need for me to go into the backend of the media centre at all. All the data is moved automatically to the correct locations, making it unnecessary to control the system with anything beyond a remote control.

I needed the script to distinguish what type of recording had taken place, whether it be a TV episode, a special or a movie. I then needed to move the various types of video to different locations and change the filename of the movies so that Media Center Master could identify the recording. It would have been nice to use meta data as identifiers of the shows, but I found that data to be very unreliable.

I run the script on a schedule through Windows Task Scheduler at 5am each morning, but it can also be launched on demand.

Because different channels show different information on the TV guide, it is impossible to make a script that will work in every instance. It manages to get the majority of moves right. Generally, it is fine to watch the occasional TV episode from the movie library. Once it is watched, deleting the file will resolve these errors. Otherwise a manual move will be required.

It is likely you will need to make minor alterations to the batch file yourself. I have my recorded TV located at D:\Recorded TV, and my movies at E:\Movies. If your files are located in different locations, you will need to make alterations. It is configured to only work with files in the dvr-ms format, though it would be very easy to change the script to move around .wtv files.

The way the script works is to break up the filename into various components.

If the filename has an Sp– at the start of it, I know it is a special so it is moved to D:\RecordedTV\Specials.
If the filename has a “)” followed by text or “M–” at the start, I know it is a movie so I alter the name and copy it to the E:\Temp. Once copied, I move the files to E:\Movies and make individual folders for each movie. The individual movies get copied into their own directory.
Any other files get put in their own directory in Recorded TV based on the title of the file.

You can download the script here (right click, save target as). It is in txt format so that you can’t inadvertently run it. If you don’t know how to convert the file to a batch file without help, please ignore this article to reduce the risk of something going wrong. Understanding how to write batch files is a very useful skill so it is worth learning, just don’t use this script as your first script. It’s quite complicated as far as batch scripts go.

Important: While it is unlikely you will lose files by running this script, it is important you understand what is going on with it. If you run it on your current media library, it will perform each task and the results may not be what you wanted. This script was written based on a Sydney TV guide. Different countries are bound to have various different identifiers. Treat this script as examples of how to make your own script.

This script is based on file2folder.bat which now has a GUI to put in the settings. These tools may also be helpful in creating your automated file management.

Related Posts

Leave a Comment

Name: (Required)

E-mail: (Required but will not be published)