Rename all files in directory from $filename_h to $filename_half?

前端 未结 11 912
执念已碎
执念已碎 2020-12-02 03:45

Dead simple.

How do I rename

05_h.png
06_h.png

to

05_half.png
06_half.png

At least, I think it\

11条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-02 04:31

    Try rename command:

    rename 's/_h.png/_half.png/' *.png
    

    Update:

    example usage:

    create some content

    $ mkdir /tmp/foo
    $ cd /tmp/foo
    $ touch one_h.png two_h.png three_h.png
    $ ls 
    one_h.png  three_h.png  two_h.png
    

    test solution:

    $ rename 's/_h.png/_half.png/' *.png
    $ ls
    one_half.png  three_half.png  two_half.png
    

提交回复
热议问题