Created
October 19, 2018 23:38
-
-
Save KristofferK/2be38228e5a68bcdd23e57b469b971a0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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