Using this extention, "Display Random Image from Folder in OBS Image Source"

Is there a way to grab just the file name and populate that to an OBS Text source… not the path or the extension. %randomImage% gives me the whole thing, path, name, extension. I would like to use the file name as a title for the image being displayed.

Display Random Image from Folder in OBS Image Source - Extensions / Approved - Streamer.bot Extensions

// === CONFIGURATION ===
bool includeExtension = true; // Set to false to remove file extension
bool isUrl = false; // Set to true if input is a URL

// === INPUT ===
string inputPath = @“C:/user/assets/avatar.png”; // Or a URL like “https://example.com/avatar.png”

// === PROCESSING ===
string filename;

if (isUrl)
{
Uri uri = new Uri(inputPath);
filename = includeExtension
? System.IO.Path.GetFileName(uri.LocalPath)
: System.IO.Path.GetFileNameWithoutExtension(uri.LocalPath);
}
else
{
filename = includeExtension
? System.IO.Path.GetFileName(inputPath)
: System.IO.Path.GetFileNameWithoutExtension(inputPath);
}

// === OUTPUT ===
StreamerBotActions.SetText(filename); // Replace with your preferred output method

this script can be dropped inline and covers if its a URL or file patrh and you can toggle true false if you want the extention or not