Special folders |
Learn about special folders
Fast video cataloger supports something we call special folders. These are path mappings where you can specify a variable as a root to a path-dependent on the system where the catalog is running. You can specify these special folders in the preference of the program. One of these special folders is [LOCAL], local gets used when you add a video below the catalog file's folder. Special folders make it possible to move around a folder with a catalog and videos in subfolders without breaking paths. So, what does this have to do with scripting? In the previous example, your printed paths perhaps looked something like this:
[LOCAL]\my-videos\test.mp4
If we want to use this as an absolute path, we need to convert it. Functions to do that are available in the Utilities interface. This interface is how you convert this to an absolute path.
IUtilities utils = scripting.GetUtilities();
string path = utils.ConvertToLocalPath(entry.FilePath);
ConvertToLocal will take a path and convert it to a local system path. If the path is already absolute, it will simply return the exact string that was input.
If we combine all we have gone through, here is the complete program to print the path of the currently selected videos
using System.Runtime; using System.Collections.Generic; using VideoCataloger; using VideoCataloger.RemoteCatalogService; class Script { static public async System.Threading.Tasks.Task Run ( IScripting scripting, string arguments ) { ISelection selection = scripting.GetSelection(); List<long> selected_videos = selection.GetSelectedVideos(); IVideoCatalogService catalog = scripting.GetVideoCatalogService(); IUtilities utils = scripting.GetUtilities(); foreach (long VideoID in selected_videos) { VideoFileEntry entry = catalog.GetVideoFileEntry( VideoID ); string path = utils.ConvertToLocalPath(entry.FilePath); scripting.GetConsole().WriteLine( path ); } } }