Enviroment: Visual Studio 2010, Windows Forms Application.
Hi! I would like to rename (batch) some files…
1.
I have (around 50 000 files): abc.mp3, def.mp3, ghi.mp3
I want: abc1.mp3, def1.mp3, ghi1.mp3
2.
I have (around 50 000 files): abc.mp3, def.mp3, ghi.mp3
I want: 1abc.mp3, 1def.mp3, 1ghi.mp3
Something similar…
FolderBrowserDialog folderDlg = new FolderBrowserDialog();
folderDlg.ShowDialog();
string[] mp3Files = Directory.GetFiles(folderDlg.SelectedPath, "*.mp3");
string[] newFileName = new string[mp3Files.Length];
for (int i = 0; i < mp3Files.Length; i++)
{
string filePath = System.IO.Path.GetDirectoryName(mp3Files[i]);
string fileExt = System.IO.Path.GetExtension(mp3Files[i]);
newFileName = mp3Files[i];
File.Move(mp3Files[i], filePath + "\\" + newFileName[1] + 1 + fileExt);
}
But this code doesn’t work. Error here… newFileName = mp3Files[i];
And I cannot to convert it correctly.
Thank You!
Fastest option would be use direct OS renaming function. Use process object to run shell CMD with /C switch. Use the “ren” command line renaming.