2 Commits
Author SHA1 Message Date
l4kr 1909b7152a Bump version to 1.0.2 2026-07-04 11:50:16 +02:00
l4kr e7c5d4aca5 add prefix to files if they don't have it 2026-07-04 11:48:44 +02:00
2 changed files with 45 additions and 3 deletions
+2
View File
@@ -9,6 +9,8 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<AssemblyName>Futonizer</AssemblyName> <AssemblyName>Futonizer</AssemblyName>
<RootNamespace>Futonizer</RootNamespace> <RootNamespace>Futonizer</RootNamespace>
<Version>1.0.2</Version>
<FileVersion>1.0.2.0</FileVersion>
<ApplicationIcon>Assets\app.ico</ApplicationIcon> <ApplicationIcon>Assets\app.ico</ApplicationIcon>
</PropertyGroup> </PropertyGroup>
+43 -3
View File
@@ -2,6 +2,7 @@ using System.Collections.ObjectModel;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Text.RegularExpressions;
using System.Threading; using System.Threading;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
@@ -77,6 +78,42 @@ public partial class MainWindow : FluentWindow
// ── Helpers ────────────────────────────────────────────────────────────── // ── Helpers ──────────────────────────────────────────────────────────────
/// <summary>
/// If the file's parent folder has a bracketed prefix (e.g. "[neoHEVC] ")
/// and the file itself doesn't, renames the file on disk to include that
/// prefix and returns the new path. Returns the original path unchanged if
/// the condition isn't met or the rename fails.
/// </summary>
private static string TryApplyFolderPrefix(string filePath)
{
string? folder = Path.GetDirectoryName(filePath);
if (string.IsNullOrEmpty(folder)) return filePath;
string folderName = Path.GetFileName(folder);
var match = Regex.Match(folderName, @"^\[.+?\] ");
if (!match.Success) return filePath;
string prefix = match.Value;
string fileName = Path.GetFileName(filePath);
if (fileName.StartsWith(prefix, StringComparison.Ordinal)) return filePath;
string newFileName = prefix + fileName;
string newFilePath = Path.Combine(folder, newFileName);
if (File.Exists(newFilePath)) return filePath;
try
{
File.Move(filePath, newFilePath);
return newFilePath;
}
catch
{
return filePath;
}
}
private static void RestartApplication() private static void RestartApplication()
{ {
try try
@@ -212,20 +249,23 @@ public partial class MainWindow : FluentWindow
&& !_fileQueue.Any(q => string.Equals(q.FilePath, p, StringComparison.OrdinalIgnoreCase))) && !_fileQueue.Any(q => string.Equals(q.FilePath, p, StringComparison.OrdinalIgnoreCase)))
.ToList(); .ToList();
var addedPaths = new List<string>();
foreach (var path in newFiles) foreach (var path in newFiles)
{ {
var item = new QueuedFileItem(path); string effectivePath = TryApplyFolderPrefix(path);
var item = new QueuedFileItem(effectivePath);
item.PropertyChanged += QueuedFileItem_PropertyChanged; item.PropertyChanged += QueuedFileItem_PropertyChanged;
_fileQueue.Add(item); _fileQueue.Add(item);
_ = ScanFileItemAsync(item); _ = ScanFileItemAsync(item);
addedPaths.Add(effectivePath);
} }
UpdateLoadingOverlay(); UpdateLoadingOverlay();
if (newFiles.Count > 0) if (addedPaths.Count > 0)
{ {
var first = _fileQueue.FirstOrDefault(q => var first = _fileQueue.FirstOrDefault(q =>
string.Equals(q.FilePath, newFiles[0], StringComparison.OrdinalIgnoreCase)); string.Equals(q.FilePath, addedPaths[0], StringComparison.OrdinalIgnoreCase));
if (first != null) FileQueueList.SelectedItem = first; if (first != null) FileQueueList.SelectedItem = first;
} }
} }