One liner to rename bunch of files

前端 未结 3 765
失恋的感觉
失恋的感觉 2021-01-02 04:32

I was looking for a linux command line one-liner to rename a bunch of files in one shot.

pattern1.a  pattern1.b pattern1.c ...

Once the com

3条回答
  •  北荒
    北荒 (楼主)
    2021-01-02 05:00

    If you happen to be using Linux, you may also have a perl script at /usr/bin/rename which cane rename files based on more complex patterns than shell globbing permits.

    The /usr/bin/rename on one of my systems is documented here. It could be used like this:

    rename "s/pattern1/pattern2/" pattern1.*
    

    A number of other Linux environments seem to have a different rename that might be used like this:

    rename pattern1 pattern2 pattern1.*
    

    Check man rename on your system for details.

提交回复
热议问题