【问题标题】:Linux - How to rename files in batch while removing pattern in filenameLinux - 如何在删除文件名中的模式时批量重命名文件
【发布时间】:2014-11-13 02:18:06
【问题描述】:

我在一个目录中有数百个文件,名称中都有后缀“_aac”。例如: weoi32rijwef_aac.mp4

如何在批处理中重命名所有这些文件以从文件名中删除“_aac”?

【问题讨论】:

    标签: linux file sh rename


    【解决方案1】:

    更简单的方法是

    cd /to/that/directory
    rename 's/_aac//' *
    

    【讨论】:

    • 这对我很有用!请记住使用“\”转义空格和其他特殊字符。例如:rename "s/some\ test//" *
    【解决方案2】:

    像这样?:

    for i in *_aac.*
    do
        mv "$i" "`echo $i | sed -e 's/_aac././'`"
    done
    

    【讨论】:

      猜你喜欢
      • 2018-11-10
      • 2013-12-16
      • 2018-06-29
      • 1970-01-01
      • 2021-06-17
      • 2015-08-15
      • 2016-04-09
      • 2019-06-25
      • 2010-10-17
      相关资源
      最近更新 更多