Bash command to remove leading zeros from all file names

前端 未结 8 1845
一整个雨季
一整个雨季 2021-02-08 23:35

I have a directory with a bunch of files with names like:

001234.jpg
001235.jpg
004729342.jpg

I want to remove the leading zeros from all file

8条回答
  •  遇见更好的自我
    2021-02-09 00:34

    sed by itself is the wrong tool for this: you need to use some shell scripting as well.

    Check Rename multiple files with Linux page for some ideas. One of the ideas suggested is to use the rename perl script:

    rename 's/^0*//' *.jpg
    

提交回复
热议问题