How to setup and manage your media library

How to prepare your media library

  1. Every movie in it's own folder, named after the movie, add the release year in brackets, e.g. “name (1960).mkv”. Follow The Movie DB for spelling and year of release.
  2. Every tvshow in it's own folder, use “name S01E01.mkv” to name the different seasons and episodes. Follow The TV DB for spelling. Add the year of release in brackets to the folder title only.
  3. Use “name (year).CD1.mkv” to name multiple files for the same movie, e.g. CD1, CD2, etc.

Read Naming video files for more information.

How to update a wrongly set up media library

When I started to set up my media library for the Popcorn Hour A-400, I decided to create folders with the main actor, and put all related movies there. I also ignored to add the year to each movie title. This is a bad idea, as all scrapers struggle with automatic movie identification. See the previous paragraph how it's done properly.

The conversion is rather time consuming, but I generated a few shell scripts to make the task easier. Most scripts run under “sh” shell which is available on every Linux system and on Synology's DSM, a few only run under “bash” shell which is not available for DSM.

Rename all video files without moving to a new folder

  1. Description: rename all files to create filenames with years, and to correct misspelled filenames.
  2. Called script: xbmc-rename from within the main movie folder.
  3. Create xbmc-rename with the following command from the parent directory of all video files, then modify the second parameter of each line in the created script with the new name:
    find -name '*.mkv' -exec echo "mv " \"{}\" \"{}\" \;
  4. Note that xbmc-rename let's you know which files it cannot rename. Rename them manually before going to the next step.

Create folders and move video files

  1. Description: create folders from filename and move filename.mkv into these folders
  2. Called script: xbmc-move-mkv from the folder where you want to place the newly created folders. All source video files must reside in a sub folder from where you call the script.
  3. Used scripts: xbmc-move-tree
  4. Usage 1: after ripping, create folders for all files and move the files into the respective folder. I rip my videos under Windows, where the linux shells are not available, so I mount the Windows drive with autofs as drive to my linux box.
  5. Usage 2: if you have started your media collection without following the naming conventions described here, and you want to change it, go to the movies folder of your media collection and first move all existing folders into a subdirectory, for example movies-old. cd to the main movies folder (not into movies-old) and run the script. After completion, movies-old will contain all directories with previous jpg and nfo files, but all video files have been moved to the movies folder into a folder for each video file.
  6. Note: if you want to preserve jpg and nfo files, copy them first into another directory. You can do this with the following script.

Preserve jpg and nfo files

  1. Description: move jpg and nfo files into a backup directory before restructuring the media collection
  2. Called scripts: xbmc-move-jpg, xbmc-move-nfo, from within the main movie folder.
  3. Used scripts: xbmc-move

Create script to remove old folders

  1. Description: creates script to remove folder names without year. Run this script before moving new folders and video files into the video folder tree. If you changed filenames other than adding the year, then you also need to add those old filenames manually to the script.
  2. Called script: xbmc-make-bat from within a folder which contains new movie folders including year in brackets.
  3. Used scripts: xbmc-list-dir
  4. Note: xbmc-list-dir does not run under “sh”, you need to run this script under “bash”

Move new folders and video files into media collection

  1. Description: run script to remove old folders first, then run this script to move new folders, move video files from same named folders, and delete the folders in the source path afterwards.
  2. Called script: xbmc-move-new from within a folder which contains new movie folders.
  3. Used scripts: xbmc-move-dir

Fix folders and files for multiple disk movies

  1. Description: the scripts introduced here cannot handle videos with more than one file belonging to the same video. To fix this, you need to create a script manually which renames and moves those video files.
  2. Called script: xbmc-cd2 from within the folder containing multiple disk video files.

Change the name of a tvseries including all episode video files

  1. Description: Use enclosed script template to manually create a script to rename a series of files with part of the filename being same
  2. Called script: xbmc-tv-rename

File naming