fixed shit with the renames

This commit is contained in:
l4kr
2026-07-04 12:01:13 +02:00
parent 1909b7152a
commit a322b6bb00
2 changed files with 27 additions and 44 deletions
+24 -1
View File
@@ -1,6 +1,7 @@
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
using System.Text.RegularExpressions;
using System.Windows;
using Futonizer.Models;
using Futonizer.Services;
@@ -110,6 +111,28 @@ public partial class ProgressWindow : FluentWindow
TotalBytesText.Text = $"{doneMb:F0} / {totalMb:F0} MB copied";
}
/// <summary>
/// If the source file's parent folder starts with a bracketed tag
/// (e.g. "[KAA]" or "[neoHEVC]") and the file name doesn't already
/// start with that tag, returns the file name with the tag prepended
/// (e.g. "[KAA] episode.mkv"). Otherwise returns the file name unchanged.
/// Only applied to the output file — the source is never touched.
/// </summary>
private static string PrefixedFileName(string sourceFilePath, string fileName)
{
string? folder = Path.GetDirectoryName(sourceFilePath);
if (string.IsNullOrEmpty(folder)) return fileName;
string folderName = Path.GetFileName(folder);
var match = Regex.Match(folderName, @"^\[.+?\]");
if (!match.Success) return fileName;
string prefix = match.Value + " "; // e.g. "[KAA] "
if (fileName.StartsWith(match.Value, StringComparison.Ordinal)) return fileName;
return prefix + fileName;
}
private static long SafeFileLength(string path)
{
try { return new FileInfo(path).Length; }
@@ -159,7 +182,7 @@ public partial class ProgressWindow : FluentWindow
{
string outputFilePath = overwritingInPlace
? file.FilePath
: Path.Combine(_outputFolder, file.FileName);
: Path.Combine(_outputFolder, PrefixedFileName(file.FilePath, file.FileName));
var videoIds = file.Tracks
.Where(t => t.Type == "video" && t.Copy)