Use Filebot to rename media files (and folders)

FileBot
FileBot

Since I am using Plex, I don’t spent time anymore to rename correctly the movies. I am only using their title for the parent folder. For series however I have, per PLEX requirement, to prefix each episode with the name of the serie + SxxEyy where xx = season and yy = episode number. I decided however recently to do some clean-up on the filenames (rename them with the exact movie title, the movie year, the video format, the audio format, etc…). As Plex can’t do that, I am using Filebot.

Click to Read More

In the past, I was a great fan of Media Browser 2.x. I was using MetaVideoEditor to download the metadata for my movies. When MetaVideoEditor ended to work (not updated anymore to download the metadata from the providers), I looked for alternatives. Alternatives to MetaVideoEditor but also possibly to Media Browser. I found Plex, coming with a media server for Synology, a media player for HTPC or Samsung TV, and its own metadata downloader. I found Plex much more mature than Media Browser 3.x and I loved that Plex Server was running on my NAS. Plex was based on XBMC but much simpler to configure and much more user friendly, especially for kids. And its metadata downloader was perfect. There was however one difference with MetaVideoEditor: it was not renaming the media file with their title, episode number, etc…

But that’s not an issue as I found Filebot, a TV and Movies renamer much better than any other similar software! It’s really amazing! It renames not only movies and episodes but also subtitles, audio files, poster (jpg, …), metadata file (xml, nfo) and checksum files (SFV, MD5, SHA-1, ED2K).

Filebot can query various providers to fetch the rename of your files: TheTVDB, AniDB, TVRAge, Serienjunkies, TheMovieDB, IMBd, OpenSubtitles. And icing on the cake, it can rename those files using your own format. I.e. you can define which information must be used to rename the files including media info extracted from the files thanks to the well know library mediaInfo. You can also call functions to transform this information like removing or replacing blanks and special characters, etc…

Ex.: if you use a format like this one to rename a file “The.Man.from.earth.Ripped.by.MySelf.from.BlueRay.XYZ“: {n} ({y}) {vf} {af}, the nale will become “The Man from Earth (2007) 720p 6ch” because “n” is a tag replaced by the name of the movie fetched from one of the provider mentionned above. “y” is the movie year. “vf” is the standard video format. “af” is the audio channels. See more tags here.

Notice that you MUST install Java x64 on your machine if you have Windows x64. Otherwise, filebot will fail to load mediainfo’s libraries. You will see the following error when trying to use custom pattern to rename the files: “BindingException: “vf”: Could not initialize class net.filebot.mediainfo.MediaInfoLibrary.

Also, asking filebot for information, in a command prompt run in C:\Program Files\FileBot, you will clearly see that there is an issue. It thinks you are on a Windows x86:

C:\Program Files\FileBot> filebot -script fn:sysinfo FileBot 4.1 (r2245) JNA Native: 4.0.0 MediaInfo: java.lang.UnsatisfiedLinkError: Unable to load library ‘mediainfo’: Native library (win32-x86/mediainfo.dll) not found in resource path ([file:/C:/Program%20Files/FileBot/FileBot.jar]) Jun 02, 2014 12:54:34 AM net.filebot.archive.SevenZipLoader requireNativeLibraries WARNING: Failed to preload library: java.lang.UnsatisfiedLinkError: no mingwm10 in java.library.path 7-Zip-JBinding: net.sf.sevenzipjbinding.SevenZipNativeInitializationException: Failed to load 7z-JBinding: C:\Program Files\FileBot\7-Zip-JBinding.dll: Can’t load AMD 64-bit .dll on a IA 32-bit platform chromaprint-tools: fpcalc version 1.1.0 (C:\Program Files\FileBot\fpcalc.exe) Extended Attributes: OK Groovy Engine: 2.3.2 JRE: Java(TM) SE Runtime Environment 1.7.0_51 JVM: 32-bit Java HotSpot(TM) Client VM OS: Windows 7 (x86) Done ?(?????)?

Go to the manual download page of Java to get the x64. Otherwise, using a x86 browser, you would get the x86 version of java by default.

  1. Once filebot installed, run it and select the “Rename” tab.
  2. Drag and drop the media files to be renamed in the “Original Files” tab. If you want to renamed series, drag & drop the root folder (For Plex, this folder has the name of the serie and contains one subfolder “Season xx” per season.). Notice that it will take time to load all the files but you won’t see any progress bar or spinning hourglass. Be patient!!!
  3. Once the files loaded, you will see an icon next to each one (on the right) mentioning the type of file (jpg, mkv, nfo, xml, …). Each of those files will be renamed. This will therefore maintain the “link” between the existing metadata and the media itself, for players like XBMC, etc…
  4. Right click on the “Match” button to select “Preference”. There, select the language of your media. “Titles” will be fetched from the providers in that language.
  5. Right click on the “Match” button to select “Edit Format” (if you want to customize it). It opens a “Format” window
  6. At the bottom of that window, click on the button “Switch to …” to select the type of media you are going to rename: Movie, Music or Episode.This is important as all tags don’t works for all type of media. Ex.: the tab {e}, “Episode Numbers”, does not exist for movies or music. The type of media you have selected is display in the title bar of the window.
  7. Bellow the format, click on “(x)=” to select one sample of media. It will show you the media information retrieved with the mediainfo library. This preview can help you to find the Tag you need for you custom format.
  8. Now, type you own format. Various samples can be found here. For my series and my movies, I am using respectively:
    {n.replaceAll(/[!?.]+$/).replaceAll(/[`´‘’ʻ]/, "'").replaceAll(/[:;]/, "-")} - {s00e00} - {episode.title.replaceAll(/[!?.]+$/).replaceAll(/[`´‘’ʻ]/, "'").replaceAll(/[:;]/, "-")} [{vf}.{vc}.{ac}]
    {n.replaceAll(/[!?.]+$/).replaceAll(/[`´‘’ʻ]/, "'").replaceAll(/[:;]/, "-")} ({y}) [{fn.match(/3D/)+"."}{fn.matchAll(/H-OU|H-TAB|HSBS|H-SBS|Half-SBS|Full-SBS|F-SBS|SBS/).join('.').replace('Half-','H-').replace('Full-','F-').replace('TAB','OU').replace('HSBS','H-SBS')+"."}{vf}.{vc}.{ac}] {" CD$pi"}
  9. Once the expression to format completed, click on Use Format. This will close the window.
  10. Right click on Match and select the provider to be used (depending on the type of media to be renamed). Filebot will immediately start to fetch the meta data from that provider and display a preview of the New Names. You will see a spinning icon in the upper right corner indicating that the operation is in progress.
  11. Once completed, you can check that everything is fine in the preview before clicking on “Rename” to execute the actual renaming.

Filebot can not only rename the files but also move them if you include a path in the format. Ex. to move Avatar.mkv into a folder like X:/Movies/Avatar Collection/Avatar (2009) /Avatar (2009).mkv, use a format like: X:/Movies/{n} ({y}).

I use the following expression to renamed the folders of my movies:

../{n.replaceAll(/[:;]/, "-")} ({y})/{n.replaceAll(/[!?.]+$/).replaceAll(/[`´‘’ʻ]/, "'").replaceAll(/[:;]/, "-")} ({y}) [{fn.match(/3D/)+"."}{fn.matchAll(/H-OU|H-TAB|HSBS|H-SBS|Half-SBS|Full-SBS|F-SBS|SBS/).join('.').replace('Half-','H-').replace('Full-','F-').replace('TAB','OU').replace('HSBS','H-SBS')+"."}{vf}.{vc}.{ac}] {" CD$pi"}

Actually the folder is not renamed, but the file is moved into a new folder instead. So, there are plenty of empty folders remaining on the system (or folder that contain only files not renamed with the movies…). To delete them run the following “groovy script” provided by filebot (in a cmd prompt run as administrator):

c:\Program Files\FileBot>filebot.exe -script fn:cleaner "\Path\To\Your\Movies" 2> filebot-error.log 1> filebot.log

If you don’t want to cleanup the empty folders without checking what will be deleted, run the same script in ‘test’ mode first and look at the log file…

c:\Program Files\FileBot>filebot.exe -script fn:cleaner "\Path\To\Your\Movies" --action test 2> filebot-error.log 1> filebot.log

 

Notice, “Advanced Renamer” can also do it but it’s not as easy. One has indeed to use javascript within “Advanced Renamer” to get access to the complete exif information. it means that a Filebot’s tag as simple as {vf} becomes in Advanced Renamed:

[js]var format = ”;
var w = item.exifToolValue(‘ImageWidth’);
var h = item.exifToolValue(‘ImageHeight’);

if (w == 0) {
format = ”;
} else if (w < 1280) {
if (h < 576) {
format = ‘SD NTSC’;
} else {
format = ‘SD PAL-SECAM’;
}
} else if (w < 1920) {
format = ‘HD 720p’;
}
else if (w < 3840) {
format = ‘HD 1080p’;
}
else if (w < 7680) {
format = ‘UHD 4K’;
}
else {
format = ‘UHD 8K’;
}

return item.newBasename + ‘(‘ + format + ‘)’;

[/js]

Download: http://www.filebot.net/

Loading


Categories:

Tags:


Comments

One response to “Use Filebot to rename media files (and folders)”

  1. Valery Letroye Avatar

    How to install filebot on a Synology: /wordpress/jdownloader-and-filebot-on-synology/

Leave a Reply

Your email address will not be published. Required fields are marked *