Auto Index Folder

Add and index a folder of videos from a script

This sample shows the basics of the IVideoIndexer interface: queue a folder of videos with AddFolder and start processing the queue with StartIndexing. Videos already in the catalog are skipped.

Pass the folder to index as the script argument.

using System;
using System.IO;
using VideoCataloger;

class Script
{
    static public async System.Threading.Tasks.Task Run(IScripting scripting, string arguments)
    {
        IConsole console = scripting.GetConsole();
        console.Clear();

        string folder = (arguments ?? "").Trim().Trim('"');
        if (folder.Length == 0)
        {
            console.WriteLine("Usage: pass the folder to index as the script argument, for example:");
            console.WriteLine("  C:\\Videos\\NewClips");
            return;
        }
        if (!Directory.Exists(folder))
        {
            console.WriteLine("Folder not found: " + folder);
            return;
        }

        IVideoIndexer indexer = scripting.GetVideoIndexer();
        indexer.AddFolder(folder, true, true); // include subfolders, skip videos already in the catalog
        indexer.StartIndexing();

        console.WriteLine("Queued videos in " + folder + " for indexing.");
        console.WriteLine("Watch progress in the Add videos window.");
    }
}