search

Home  >  Q&A  >  body text

mongodb - bash 批量重命名

当下有许多 mp3 文件,文件名如下

1-music1.mp3
2-music2.mp3
3-music3.mp3
4-music4.mp3
5-music5.mp3
.....
10-music.mp3

如何批量去除前面的前缀。

黄舟黄舟2795 days ago854

reply all(4)I'll reply

  • 天蓬老师

    天蓬老师2017-04-25 09:03:54

    I misread the question, it’s about batch renaming
    You can use the
    ls和管道和renamecommand
    for batch renaming Similar to the following batch delete command.

    ls | grep "^[0-9]{1,2}-music.mp3" | xargs -d"n" rm
    http://superuser.com/questions/392872/delete-files-with-regular-expression

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-04-25 09:03:54

    perl-rename 's/prefix/replacement/'

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-04-25 09:03:54

    for i in $( seq 1 10 );do
    mv $i-music$i.mp3 music$i,mp3;
    done

    reply
    0
  • 为情所困

    为情所困2017-04-25 09:03:54

    rename 's/^.*-\(.*\.mp3\)//' *.mp3

    This will delete the aaa- in the name aaa-bbb.mp3;

    reply
    0
  • Cancelreply