开发者

Removing file extensions batch or c#

开发者 https://www.devze.com 2023-03-24 21:34 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消