我有数千个文件,文件扩展名如下所示:
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上执行此操作的任何方法?
ls | xargs -I % mv % %.html
的每个部分的作用?我的意思是为什么要使用-I
? - Ranveer-I
定义了要替换的字符串。在这个例子中,我使用了%
符号。它不一定是单个字符,但通常更容易理解正在发生的事情。因此,它意味着 xargs 将替换来自ls
(或find
)命令的所有后续出现的%
符号的输入。例如,echo 1 | xargs -I % echo %%%
将在控制台上打印111
。 - julumme