-- Introduction --
If you use software like XBMC, renaming and sorting downloaded files can be tedious, and making them continue seeding often requires copying, eating up disk space. In this tutorial I'll show you how to use uTorrent and FileBot, an open source file renamer, to automatically rename files, as well as fetching subtitles to a new location without using more disk space and without disturbing the original files at all. We will create a script in FileNamer that allows it to watch a folder for changes to allow this.
-- Understanding Copy, Soft Links and Hard Links --But how is it possible to copy a file without eating more disk space? The answer is actually simple, and is a very smart solution called a hard link.
I will further explain how a hard link works later, but first we'll look at the basics and the two other ways of creating a copy of a file while still seeding. The first and most obvious is a ā€‹copyā€‹.
Now in our OS, we see our files as a file in a folder. But that isn't really where the file is located. The file you see in the folder is actually just a link that points to the physical location of your file on your computer. This is true for all files in your file system. In the same way folder are actually not files, they just help you organise these "links" to your files. Think of it like this:
As you can see, the file on the hard drive is not sorted in any way. The file system points to the unsorted file.
Now, what a copy does, is to create a copy of the ENTIRE physical file on the hard drive. This is needed for many purposes, but for ours it's time consuming and tedious. Another variant is soft link. A soft link is similar to a Windows shortcut in that it creates a link to the original link on your hard drive, like this:
Soft links do not use any considerable HDD space, and are great for links to permanent files. However, a seeding torrent you might delete in the soon future, ruining the soft link as it's got nothing to point to.
A hard link, on the other hand, works like this:
It is not dependent on any other link in the file system, as it works as the original link itself, pointing directly to the file on the HDD, which is not deleted until BOTH hard links are deleted. Perfect for our purposes.
-- Downloading and Configuring FileBot and uTorrent --
Now, as I said, this requires configuring uTorrent to our purpose and dowā€‹nloading FileBot. FileBot is free and open source for Windows, Mac, and Linux. It includes a GUI application, but for this purpose we'll use the CLI (command line interface). I suggest you go ahead and download FileBot now, before we continue. For FileBot to work properly you also need to make sure you have Java 7 installed. Windows users can go ahead and download Java 7 from here. For mac users it's a bit harder: Apple supplies it's own version of Java, and updates are delayed considerably. This means you have to download a third-party build, I suggest downloading the latest stable installer build from here.
We'll start by configuring uTorrent. uTorrent needs to be configured to move finished downloads to another folder. Go ahead and create a folder anywhere on your Mac or PC where you won't accidentally delete it, i titled mine "finisheddownloads". Not having any spaces in your folder path is of great help. Now open uTorrent and go to Settings, select "move completed downloads to" and find your folder. If you want to have control of which downloads are put in this folder, select, only move from default download directory and select another download path for these downloads. This is useful if you are downloading other things than movies and TV shows, as it speeds up FileBots sorting process. Moving movies and TV shows after downloading is essential to FileBot, as it will run whenever new files are added - including .part files and similar.
Now we can start by configuring FileBot. As I said, we're not actually going to use the GUI, but rather the CLI. For Windows users the CLI is installed automatically, Mac users need to right-click the .app, select "show package contents" and navigate to /contents/macOS/. Now open a Terminal window (easily done by clicking the Spotlight magnifying glass in the upper right corner and typing in terminal) and drag the install.sh file into the terminal window, and hit enter. This will run the file. If you do not have permissions to run this file, type sudo and then drag the file into the terminal. Enter your password when prompted. This will run the file with admin privileges.
Finally, the scripting. I am including a sample script that will watch the folder for changes and run whenever files are added. The script includes functions to extract files from .rar files and other archives, sorting the movies and TV shows into separate paths and fetching subtitles. Other features can be mostly copy-and-pasted from other scripts, many can be found here.
The script itself can be downloaded from here. After you download the script you need to customise it by opening it, preferably in a code editor but alternatively in a notepad on windows or textedit on mac. If you use these then make sure the extension is .groovy and not .txt or similar. DO NOT open in word or a similar editor. Enter the paths to all the folders like the file says, removing the brackets around all of the paths. Use a different path for movies and TV shows.
To run the script, copy the first line, the one that starts with ////, but do not include ////. Now just open a CMD or Terminal window, copy the line you just copied (without ////), hit enter and you're ready to go!
Any questions, ask in the comments. If you want to include the script for troubleshooting, please do so by PM-ing me the entire text of the script including your personal paths. I need to see these, and others don't. For the best possible troubleshooting, post in the FileBot forums. The creator of FileBot is super helpful, and is glad to help troubleshooting scripts.
-- Tips & Tricks --
It's possible to run the script on startup and in the background by creating a mix of .bat and .vbs files - one .bat file in the registry to launch the .vbs, and the .vbs to launch another .bat in a hidden mode, the .bat with your script. I might add details on this later, but google is a great resource
To launch the command hidden on startup on a mac, you simply have to create a automator script.
XBMC can be set to scrape the new files automatically on startup, fetching cover art and organising them.
If you want to further customise your scripts, the FileBot forums are a great resource to finding snippets you can copy and paste in.
You can of course use other BitTorrent clients than uTorrent, but they need the functionality to move finished files to another folder.
Good luck sorting movies!