Created
June 13, 2016 05:46
-
-
Save KirillOsenkov/a28fda36d16dca9c85ab46dc3deec101 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.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