Click or drag to resize

RenameToDate

Rename videos to the file file date

Shows some file operations and how it can be combined with Fast Video Cataloger scripting. First we get the selected videos. The for each selected video we find the creation date of the video file. We generate an iso style date i.e yymmdd and then rename the video to follow that standard. The nice thing with iso style dates is that you can sort them by filename and get them in chronological order. We the update the catalog with the changed named and finally refreshes the gui.

Example
C#
using System;
using System.IO;
using System.Runtime;
using System.Collections.Generic;
using VideoCataloger;

/// <summary>
///  This sample takes the currently selected videos, check the date of the video file and rename the 
///  video file to the date of the file.  
/// </summary>
class Script
{
    static public async System.Threading.Tasks.Task Run(IScripting scripting, string arguments)
    { 
        scripting.GetConsole().Clear();
        ISelection selection = scripting.GetSelection();
        List<long> selected = selection.GetSelectedVideos();
        foreach (long video in selected)
        {
            // Get the video file entry
            var entry = scripting.GetVideoCatalogService().GetVideoFileEntry(video);
            scripting.GetConsole().WriteLine(System.Convert.ToString("Processing..." + entry.FilePath));

            // Get the date of the file
            DateTime creation = File.GetCreationTime(entry.FilePath);
            String creeation_string = creation.ToString("yyyyMMdd_HHmmss");

            // Copy the video file type extension
            var extension_start = entry.FilePath.LastIndexOf(".");
            creeation_string += entry.FilePath.Substring(extension_start);

            // and create the path to the file.
            var path_end = entry.FilePath.LastIndexOf("\\");
            String target_path = entry.FilePath.Substring(0, path_end);
            scripting.GetConsole().WriteLine(System.Convert.ToString("Newname to:" + target_path + "\\" + creeation_string));

            // rename the file
            System.IO.File.Move(entry.FilePath, target_path + "\\" + creeation_string);

            // and update the catalog witb the new file path
            scripting.GetVideoCatalogService().SetVideoProperty(video, "FilePath", target_path + "\\" + creeation_string);
        }

        // refresh the gui to show the changed file paths.
        scripting.GetGUI().Refresh("");
    } 
}