Skip to content

Instantly share code, notes, and snippets.

@KristofferK
Created October 19, 2018 23:38
Show Gist options
  • Save KristofferK/2be38228e5a68bcdd23e57b469b971a0 to your computer and use it in GitHub Desktop.
Save KristofferK/2be38228e5a68bcdd23e57b469b971a0 to your computer and use it in GitHub Desktop.
using System;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
namespace DougRenamer
{
class Program
{
private const string DIRECTORY = @"D:\Deluge\Doug\";
static void Main(string[] args)
{
Directory.GetFiles(DIRECTORY).ToList().ForEach(RenameFile);
}
private static void RenameFile(string path)
{
var file = path.Substring(DIRECTORY.Length);
var match = Regex.Match(file, "doug([1-9])([0-9]{2})\\.(.+)").Groups.Select(e => e.Value).ToArray();
var newFile = $"Doug S0{match[1]}E{match[2]}.{match[3]}";
Console.WriteLine($"Before: {path}");
Console.WriteLine($"After: {DIRECTORY + newFile}");
Console.WriteLine();
File.Move(path, DIRECTORY + newFile);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment