Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var drives = DriveInfo.GetDrives();
- drives.AsParallel().ForAll(d =>
- {
- RenameAllPngFiles(d.Name);
- });
- .....
- static void RenameAllPngFiles(string sDir)
- {
- try
- {
- Directory.EnumerateFiles(sDir, "*.png")
- .AsParallel()
- .WithDegreeOfParallelism(10)
- .ForAll(TryRenameImage);
- } catch { } //If I don't have access to one of the sub folders
- try
- {
- foreach (string path in Directory.EnumerateDirectories(sDir))
- {
- RenameAllPngFiles(path);
- }
- }
- catch (System.Exception excpt) //If I don't have access to one of the sub folders
- {
- //Console.WriteLine(excpt.Message);
- }
- }
- private static void TryRenameImage(string path)
- {
- try
- {
- File.Move(path, path.Replace("hex",""));
- }
- catch ()
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement