Bash command to remove leading zeros from all file names

前端 未结 8 1870
一整个雨季
一整个雨季 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:23

    In Bash, which is likely to be your default login shell, no external commands are necessary.

    shopt -s extglob
    for i in 0*[^0]; do mv "$i" "${i##*(0)}"; done
    

提交回复
热议问题