【发布时间】:2011-04-02 05:08:27
【问题描述】:
我有一个文件夹,其中的文件名为
input (1).txt
input (2).txt
input (3).txt
...
input (207).txt
如何将它们重命名为
input_1.in
input_2.in
input_3.in
...
input_207.in
我正在尝试这个
for f in *.txt ; do mv $f `echo $f | sed -e 's/input\ (\(\d*\))\.txt/input_\1.in/'` ; done
但它给了我
mv: target `(100).txt' is not a directory
mv: target `(101).txt' is not a directory
mv: target `(102).txt' is not a directory
...
我哪里做错了?
我现在已经加了引号,但我现在明白了
mv: `input (90).txt' and `input (90).txt' are the same file
它以某种方式试图将文件重命名为相同的名称。这是怎么回事?
【问题讨论】: