Rename small part of multiple files in middle of name using Bash?

前端 未结 4 1933
孤独总比滥情好
孤独总比滥情好 2021-02-04 04:15

I\'d just like to change this

cc211_AMBER_13062012i.II  cc211_GROMOS_13062012i.II
cc211_CHARM_13062012i.II  cc211_OPLS_13062012i.II

to

4条回答
  •  隐瞒了意图╮
    2021-02-04 04:45

    I'm using a pure Linux solution:

    ### find all files that contains _DES in name and duplicate them adding _AUXLOCAL
    for f in **/*_DES*; do
        cp "$f" "${f%.DES}_AUXLOCAL"
    done 
    ###Rename all _AUXLOCAL files, removing _DES to _LOCAL
    for f in **/*_AUXLOCAL*; do
      mv "$f" "${f/_DES/_LOCAL}"
    done
    ###Rename all _AUXLOCAL files, removing _AUXLOCAL
    for f in **/*_AUXLOCAL*; do
      mv "$f" "${f/_AUXLOCAL/}"
    done
    

    I hope it helps

提交回复
热议问题