Is there a way to mass remove file extensions in batch or c#
I have found ren *.loaded *.torrent very handy but with the files I work with the .loaded come after an .torrent extension, using the ren trick it becomes *.torrent.torrent :P (a bit OCD on file names).
So is there a way I can remove the file extension or would it be better to use another extension开发者_运维问答 renaming solution?
Thanks in advance :)
(I thought c# as it might be great to let the user enter the extensions to change - though I could add this myself later, no idea how to start :P)
You can do it like this
rename *.* *.torrent
to remove extentions
rename *.* *.
Using .Net
you can do something like this:
DirectoryInfo dir = new DirectoryInfo(@"C:\PathName");
foreach (FileInfo fileInfo in dir.GetFiles("*.*"))
{
File.Move(fileInfo.FullName, fileInfo.FullName.Replace(fileInfo.Extension, string.Empty));
}
You can replace *.*
or string.Empty
with other extensions.
精彩评论