Compare commits

...

5 Commits

Author SHA1 Message Date
6416d983cd Update config.json
Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com>
2025-11-18 16:26:06 +07:00
a318d2e625 1.2
Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com>
2025-10-10 22:07:04 +07:00
2cc96ff67c Add drag'n'drop to executable
Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com>
2025-10-10 22:03:02 +07:00
901f35870f 1.1
Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com>
2025-09-28 18:05:19 +07:00
020412e3a8 Update files
Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com>
2025-09-28 18:04:10 +07:00
4 changed files with 30 additions and 19 deletions

View File

@@ -156,9 +156,8 @@ namespace EpisodeRenamer
try
{
// Переводим консоль на передний план для лучшего захвата клавиш
_listenerTask = Task.Run(() => ListenForHotkeys(_cancellationTokenSource.Token),
_cancellationTokenSource.Token);
_cancellationTokenSource.Token);
await Task.CompletedTask;
}
@@ -194,7 +193,8 @@ namespace EpisodeRenamer
await _listenerTask.ContinueWith(t =>
{
// Игнорируем исключения отмены задачи
if (t.IsFaulted) OnError?.Invoke(t.Exception);
if (t.IsFaulted)
OnError?.Invoke(t.Exception);
});
}
}

View File

@@ -4,7 +4,6 @@ using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
namespace EpisodeRenamer
@@ -45,6 +44,29 @@ namespace EpisodeRenamer
static async Task Main(string[] args)
{
if (args.Length > 0)
{
try
{
LoadConfiguration();
}
catch (Exception ex)
{
Console.WriteLine($"Ошибка загрузки конфигурации: {ex.Message}");
Console.WriteLine("Программа будет завершена.");
Console.ReadLine();
return;
}
foreach (string line in args)
if (Directory.Exists(line))
{
ProcessFolder(line);
Console.WriteLine();
}
Console.ReadLine();
return;
}
// Создаем экземпляр слушателя
using (var hotkeyListener = new HotkeyListener())
{
@@ -57,8 +79,6 @@ namespace EpisodeRenamer
LoadConfiguration(true);
break;
case "ControlC":
Console.WriteLine("\nВыход из программы.");
Thread.Sleep(1500);
Environment.Exit(0);
break;
default:
@@ -97,12 +117,6 @@ namespace EpisodeRenamer
return;
}
//Console.CancelKeyPress += (sender, e) =>
//{
// Console.WriteLine("\nВыход из программы.");
// Environment.Exit(0);
//};
Console.WriteLine("Чтобы оставить текущую директорию нажмите 'Enter'");
Console.WriteLine("Чтобы перезагрузить конфигурацию нажмите 'Ctrl + Alt + R'");
Console.WriteLine("Чтобы выйти нажмите 'Ctrl + C'");
@@ -141,15 +155,14 @@ namespace EpisodeRenamer
{
extensions.Clear();
patterns.Clear();
GC.Collect();
Console.WriteLine("\nЗапрошена перезагрузка конфигурации.");
}
string configPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config.json");
if (!File.Exists(configPath))
{
throw new FileNotFoundException("Конфигурационный файл config.json не найден");
}
string json = File.ReadAllText(configPath);
Config config = JsonConvert.DeserializeObject<Config>(json);
@@ -180,9 +193,7 @@ namespace EpisodeRenamer
string extension = Path.GetExtension(fileName);
if (extensions.Contains(extension))
{
RenameFile(filePath, fileName, folder);
}
}
}

View File

@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Номер сборки
// Номер редакции
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.2.0.0")]
[assembly: AssemblyFileVersion("1.2.0.0")]

View File

@@ -22,7 +22,7 @@
},
{
"Enabled": false,
"Regex": "[ ]\\d[2][ ]",
"Regex": "[ ]\\d{2}[ ]",
"Start": 1,
"End": null
},