I have over 1000 files in a folder with names like abc_1, abc_2 ... abc_n
I want to delete this prefix 'abc_' from all the files. Any chance to not doing this manually because there are over 1000, and it will be a pain.
How can do this with c# ?
By Using cp CommandWe can use cp commands along with destination and source only. Here along with the file's path, the filename is also changed—the syntax for the cp command.
You can try with this code
DirectoryInfo d = new DirectoryInfo(@"C:\DirectoryToAccess"); FileInfo[] infos = d.GetFiles(); foreach(FileInfo f in infos) { File.Move(f.FullName, f.FullName.Replace("abc_","")); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With