使用Bash在名称中间重命名多个文件的一小部分吗? [英] Rename small part of multiple files in middle of name using Bash?
本文介绍了使用Bash在名称中间重命名多个文件的一小部分吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只想更改
cc211_AMBER_13062012i.II cc211_GROMOS_13062012i.II
cc211_CHARM_13062012i.II cc211_OPLS_13062012i.II
到
cc211_AMBER_15062012i.II cc211_GROMOS_15062012i.II
cc211_CHARM_15062012i.II cc211_OPLS_15062012i.II
我尝试过
find -name "*.13 *" | xargs rename ".13" ".15"
在第3个星号和第二个星号之间通常没有空格,从我所看到的来看,这就是使其变为斜体.基本上,对于在文件名末尾的操作有很多答案,而asterix似乎可以在其中工作,但是在这里我无法使其工作.
There is normally no space between the 3 and the second asterix, thats just makes it italics on from what I can see. Basically there's a lot of answers for what to do when it's at the end of the filename, where asterix seem to work, but here I can't make it work.
您拥有的任何东西都会使我的生活更加轻松!
Anything you've got would make my life a lot easier!
试用版
-bash-4.1$ ls
cc211_AMBER_13062012.II cc211_GROMOS_13062012.II
cc211_CHARM_13062012.II cc211_OPLS_13062012.II
-bash-4.1$ rename 's/_13/_15/' cc*
-bash-4.1$ ls
cc211_AMBER_13062012.II cc211_GROMOS_13062012.II
cc211_CHARM_13062012.II cc211_OPLS_13062012.II
推荐答案
这是怎么回事:
for i in *.II; do mv $i $(echo $i | sed 's/_13/_15/g'); done
这将在所有扩展名为 .II
有关sed的更多信息,此处.
More information on sed here.
这篇关于使用Bash在名称中间重命名多个文件的一小部分吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文