Skip to content

Instantly share code, notes, and snippets.

@KirillOsenkov
Created June 13, 2016 05:46
Show Gist options
  • Save KirillOsenkov/a28fda36d16dca9c85ab46dc3deec101 to your computer and use it in GitHub Desktop.
Save KirillOsenkov/a28fda36d16dca9c85ab46dc3deec101 to your computer and use it in GitHub Desktop.
using System.IO;
using System.Linq;
class FileRangeRenamer
{
static void Main(string[] args)
{
var folder = @"D:\Photos\June12\Clouds1";
var files = Directory.GetFiles(folder, "*.CR2").OrderBy(f => f).ToArray();
foreach (var file in files)
{
var fileName = Path.GetFileNameWithoutExtension(file).Substring(4);
if (fileName.StartsWith("9"))
{
var newName = "IMG_" + (int.Parse(fileName) - 1000).ToString();
File.Move(file, Path.Combine(folder, newName + ".CR2"));
}
else if (fileName.StartsWith("0"))
{
var newName = "IMG_" + (int.Parse(fileName) + 9000).ToString();
File.Move(file, Path.Combine(folder, newName + ".CR2"));
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment