在linux或windows中更改目录中的所有文件名和扩展名

Ven*_*raj 5 linux windows file-management file-rename

我有成千上万的文件扩展名,像这样

3_bedroom_villas_in_chennai.html__201308050010_
3_bedroom_villas_in_chennai.html__201308080012_
3_bedroom_villas_in_chennai.html__201308100012_
3_bedroom_villas_in_chennai.html__201308110034_ and so on.....
Run Code Online (Sandbox Code Playgroud)

在目录中.我想将所有这些改为以下内容

3_bedroom_villas_in_chennai__201308050010_.html
3_bedroom_villas_in_chennai__201308080012_.html
3_bedroom_villas_in_chennai__201308100012_.html
3_bedroom_villas_in_chennai__201308110034_.html
Run Code Online (Sandbox Code Playgroud)

当我尝试使用以下命令在Windows中执行此操作时

ren *.* *.html
Run Code Online (Sandbox Code Playgroud)

我得到了以下内容

A duplicate file name exists, or the file
cannot be found.
A duplicate file name exists, or the file
cannot be found.
A duplicate file name exists, or the file
cannot be found.
A duplicate file name exists, or the file
cannot be found. and so on...
Run Code Online (Sandbox Code Playgroud)

因为我知道它会尝试将所有内容更改为单个文件名

3_bedroom_villas_in_chennai.html and so on... 
Run Code Online (Sandbox Code Playgroud)

在Windows或Linux上做任何方法?

jul*_*mme 8

Linux中:

ls | xargs -I % mv % %.html
Run Code Online (Sandbox Code Playgroud)

ls命令输出通过管道输出xargs,xargs用mv输入替换所有%(后)ls

此外,如果您想递归遍历所有子目录,您可能希望使用:

find . -type f | xargs -I % mv % %.html
Run Code Online (Sandbox Code Playgroud)

Windows中:

for /r %x in (*) do ren "%x" *.txt
Run Code Online (Sandbox Code Playgroud)