Skip to content

Instantly share code, notes, and snippets.

@xparadoxical
Created August 18, 2023 16:12
Show Gist options
  • Save xparadoxical/095c1568abbb9406a0d91cc1bdb153e1 to your computer and use it in GitHub Desktop.
Save xparadoxical/095c1568abbb9406a0d91cc1bdb153e1 to your computer and use it in GitHub Desktop.
śwk renamer (RoslynPad)
using System.IO;
using System;
string pls = await File.ReadAllTextAsync(@"D:\Świat Według Kiepskich\kiepscy_wszystkie_sezony.pls");
var nameToTitle = pls.Split("\r\n\r\n").Skip(1).Take(588).Select(entry =>
{
var lines = entry.Split("\r\n");
return (lines[0][(lines[0].LastIndexOf('/') + 1)..], lines[1][(lines[1].IndexOf('=') + 1)..]);
}).ToDictionary(entry => entry.Item1, entry => entry.Item2);
const string dir = @"D:\Świat Według Kiepskich";
foreach (var file in Directory.EnumerateFiles(dir, "*.mp4"))
{
if (!nameToTitle.TryGetValue(Path.GetFileName(file), out var title))
continue;
try {
File.Move(file, Path.Join(dir, title + ".mp4"));
} catch (Exception e) {
Console.WriteLine(file);
Console.WriteLine(Path.Join(dir, title + ".mp4"));
e.Dump();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment