Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ______MAIN________
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- using System.Diagnostics;
- using System.Threading;
- using System.Text.RegularExpressions;
- namespace BatchRenamer
- {
- class Program
- {
- static void Main(string[] args)
- {
- int meme;
- string directory = @"C:\Users\Cyanisyde\Desktop\testfolder";
- FileHandler fG = new FileHandler(directory);
- //FileHandler[] allFilesInFolder = fG.fetchFiles(directory);
- Flow flow = new Flow();
- flow.showFolderContent(fG.fetchFiles(directory));
- Thread.Sleep(2000);
- Console.Clear();
- foreach (FileInfo file in fG.fetchFiles(directory))
- {
- if (file.ToString().EndsWith(".flac"))
- {
- Debug.WriteLine("LENGTH = " + file.ToString().Length);
- Debug.WriteLine("INDEX = " + file.ToString().LastIndexOf("-"));
- meme = file.ToString().LastIndexOf("-") + 2 + file.ToString().Length - file.ToString().LastIndexOf("-") - 1;
- Debug.WriteLine("XDD = " + meme);
- string newName = file.ToString().Substring(file.ToString().LastIndexOf("-")+2, (int)file.ToString().Length - (int)file.ToString().LastIndexOf("-") - 2);
- File.Move(file.FullName, Path.Combine(directory, newName));
- }
- }
- Console.ReadKey();
- }
- }
- }
- _____FLOW.CS_____
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- namespace BatchRenamer
- {
- public class Flow
- {
- public void showFolderContent(FileInfo[] allFiles)
- {
- for (int i = 0; i < allFiles.Length; i++)
- {
- Console.WriteLine(allFiles[i]);
- }
- }
- }
- }
- ______FILEHANDLER.CS________
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- using System.Diagnostics;
- namespace BatchRenamer
- {
- public class FileHandler
- {
- string directoryName;
- List<string> folderFiles = new List<string>();
- public FileHandler(string directoryName)
- {
- this.directoryName = directoryName;
- }
- public FileInfo[] fetchFiles(string directoryName)
- {
- DirectoryInfo d = new DirectoryInfo(directoryName);
- FileInfo[] files = d.GetFiles("*");
- //for (int i = 0; i < files.Count(); i++)
- //{
- // folderFiles.Add(files[i].ToString());
- //}
- //return folderFiles;
- return files;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement