壳牌/猛砸快捷方式的文件夹中的文件重命名散装 [英] Shell/Bash shortcut for bulk renaming of files in a folder
本文介绍了壳牌/猛砸快捷方式的文件夹中的文件重命名散装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有壳牌/ Bash的快捷方式,可以基于正则表达式或其他标准的文件夹中重命名的所有文件。我在找在这里是我的文件夹中的文件,有让我们说有以下命名约定100的文本文件:
Is there a shortcut in Shell/Bash that can rename all the files in a folder based on a regex or some other criteria. What I am looking for here is in my folder documents, that has let's say a 100 text files with the following naming convention:
<longdocumentidentifier>-doc-<counter>.txt.
我需要重命名所有上面给出的约定的文件只是:
I need to rename all the files with the above given convention to just:
doc-<counter>.txt
有一个班轮,可以帮助我与上面?
Is there a one-liner that can help me with the above?
推荐答案
我建议是这样的:
for i in *-doc-*.txt; do mv $i ${i/*-doc-/doc-}; done
请参阅http://tldp.org/LDP/abs/html/parameter-substitution.html#EX$p$pPL1了解更多详情
这篇关于壳牌/猛砸快捷方式的文件夹中的文件重命名散装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文