Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 KB | None | 0 0
  1. ______MAIN________
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.IO;
  8. using System.Diagnostics;
  9. using System.Threading;
  10. using System.Text.RegularExpressions;
  11.  
  12. namespace BatchRenamer
  13. {
  14. class Program
  15. {
  16. static void Main(string[] args)
  17. {
  18. int meme;
  19. string directory = @"C:\Users\Cyanisyde\Desktop\testfolder";
  20. FileHandler fG = new FileHandler(directory);
  21. //FileHandler[] allFilesInFolder = fG.fetchFiles(directory);
  22. Flow flow = new Flow();
  23.  
  24. flow.showFolderContent(fG.fetchFiles(directory));
  25.  
  26. Thread.Sleep(2000);
  27. Console.Clear();
  28.  
  29. foreach (FileInfo file in fG.fetchFiles(directory))
  30. {
  31. if (file.ToString().EndsWith(".flac"))
  32. {
  33. Debug.WriteLine("LENGTH = " + file.ToString().Length);
  34. Debug.WriteLine("INDEX = " + file.ToString().LastIndexOf("-"));
  35. meme = file.ToString().LastIndexOf("-") + 2 + file.ToString().Length - file.ToString().LastIndexOf("-") - 1;
  36. Debug.WriteLine("XDD = " + meme);
  37. string newName = file.ToString().Substring(file.ToString().LastIndexOf("-")+2, (int)file.ToString().Length - (int)file.ToString().LastIndexOf("-") - 2);
  38. File.Move(file.FullName, Path.Combine(directory, newName));
  39. }
  40. }
  41.  
  42.  
  43.  
  44. Console.ReadKey();
  45.  
  46.  
  47. }
  48. }
  49. }
  50.  
  51.  
  52.  
  53. _____FLOW.CS_____
  54. using System;
  55. using System.Collections.Generic;
  56. using System.Linq;
  57. using System.Text;
  58. using System.Threading.Tasks;
  59. using System.IO;
  60.  
  61. namespace BatchRenamer
  62. {
  63. public class Flow
  64. {
  65.  
  66. public void showFolderContent(FileInfo[] allFiles)
  67. {
  68. for (int i = 0; i < allFiles.Length; i++)
  69. {
  70. Console.WriteLine(allFiles[i]);
  71. }
  72. }
  73.  
  74.  
  75. }
  76. }
  77.  
  78.  
  79.  
  80. ______FILEHANDLER.CS________
  81. using System;
  82. using System.Collections.Generic;
  83. using System.Linq;
  84. using System.Text;
  85. using System.Threading.Tasks;
  86. using System.IO;
  87. using System.Diagnostics;
  88.  
  89. namespace BatchRenamer
  90. {
  91. public class FileHandler
  92. {
  93. string directoryName;
  94. List<string> folderFiles = new List<string>();
  95.  
  96.  
  97. public FileHandler(string directoryName)
  98. {
  99. this.directoryName = directoryName;
  100. }
  101.  
  102.  
  103. public FileInfo[] fetchFiles(string directoryName)
  104. {
  105. DirectoryInfo d = new DirectoryInfo(directoryName);
  106. FileInfo[] files = d.GetFiles("*");
  107.  
  108. //for (int i = 0; i < files.Count(); i++)
  109. //{
  110. // folderFiles.Add(files[i].ToString());
  111. //}
  112. //return folderFiles;
  113. return files;
  114. }
  115.  
  116.  
  117.  
  118.  
  119. }
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement