我有数以千计的文件扩展名,如此
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.....
在目录中。我想将所有这些改为以下
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
当我尝试使用以下命令在Windows中执行此操作时
ren *.* *.html
我得到以下
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...
因为我知道它会尝试将所有内容更改为单个文件名,例如
3_bedroom_villas_in_chennai.html and so on...
在Windows或Linux上执行此操作的任何方法??
答案 0 :(得分:8)
在 Linux :
中ls | xargs -I % mv % %.html
ls
命令输出通过管道传输到xargs
,xargs用来自mv
ls
之后)
此外,如果您想以递归方式遍历所有子目录,则可能需要使用:
find . -type f | xargs -I % mv % %.html
在 Windows :
中for /r %x in (*) do ren "%x" *.txt
答案 1 :(得分:1)