xerasy

Untitled

Jul 12th, 2017
93
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var drives = DriveInfo.GetDrives();  
  2. drives.AsParallel().ForAll(d =>
  3.             {
  4.                 RenameAllPngFiles(d.Name);
  5.             });
  6.  
  7. .....
  8.  
  9.   static void RenameAllPngFiles(string sDir)
  10.         {
  11.             try
  12.             {
  13.              
  14.                 Directory.EnumerateFiles(sDir, "*.png")
  15.                     .AsParallel()
  16.     .WithDegreeOfParallelism(10)
  17.     .ForAll(TryRenameImage);
  18.  
  19.  
  20.             } catch { } //If I don't have access to one of the sub folders
  21.  
  22.             try
  23.             {
  24.  
  25.                 foreach (string path in Directory.EnumerateDirectories(sDir))
  26.                 {
  27.                         RenameAllPngFiles(path);
  28.                 }
  29.             }
  30.             catch (System.Exception excpt) //If I don't have access to one of the sub folders
  31.             {
  32.                 //Console.WriteLine(excpt.Message);
  33.             }
  34.  
  35.         }
  36.  
  37. private static void TryRenameImage(string path)
  38. {
  39.     try
  40.     {
  41.         File.Move(path, path.Replace("hex",""));
  42.     }
  43.     catch ()
  44.     {
  45.     }
  46.  
  47. }
RAW Paste Data