Skip to content

Instantly share code, notes, and snippets.

@jeremybeavon
Created February 13, 2016 20:15
Show Gist options
  • Save jeremybeavon/11da077d3e2054d7a9e6 to your computer and use it in GitHub Desktop.
Save jeremybeavon/11da077d3e2054d7a9e6 to your computer and use it in GitHub Desktop.
C# Interactive function for renaming files
public static void RenameFiles(string directory, string fileMatch, string replacement)
{
foreach (string file in Directory.GetFiles(directory))
{
File.Move(file, Path.Combine(Path.GetDirectoryName(file), System.Text.RegularExpressions.Regex.Replace(Path.GetFileName(file), fileMatch, replacement)));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment