加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

shell – 如何通过替换文件名中的单词来重命名多个文件?

发布时间:2020-12-15 18:44:12 所属栏目:安全 来源:网络整理
导读:将ACDC更换为AC-DC 例如,我们有这些文件 ACDC – Rock N’ Roll Ain’t Noise Pollution.xxx ACDC – Rocker.xxx ACDC – Shoot To Thrill.xxx 我希望他们成为: AC-DC – Rock N’ Roll Ain’t Noise Pollution.xxx AC-DC – Rocker.xxx AC-DC – Shoot To
将ACDC更换为AC-DC

例如,我们有这些文件

ACDC – Rock N’ Roll Ain’t Noise Pollution.xxx

ACDC – Rocker.xxx

ACDC – Shoot To Thrill.xxx

我希望他们成为:

AC-DC – Rock N’ Roll Ain’t Noise Pollution.xxx

AC-DC – Rocker.xxx

AC-DC – Shoot To Thrill.xxx

我知道sed或awk用于此操作.我不能谷歌任何东西,所以我要求你的帮助=)你能为这项任务提供完整的shell命令吗?

反馈:Solution for OSX users

rename 's/ACDC/AC-DC/' *.xxx

从男人重命名

DESCRIPTION
       "rename" renames the filenames supplied according to the rule specified as the 
first argument.  The perlexpr argument is a Perl expression which is expected to modify the 
$_ string in Perl for at least some of the filenames specified.  If a given filename is not 
modified by the expression,it will not be renamed.  If no filenames are given on
           the command line,filenames will be read via standard input.

例如,要重命名匹配“* .bak”的所有文件以剥离扩展名,您可能会说

rename 's/.bak$//' *.bak

要将大写名称翻译为较低的名称,您可以使用

rename 'y/A-Z/a-z/' *

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读