Bash command to remove leading zeros from all file names

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

    Maybe not the most elegant but it will work.

    for i in 0*
    do
    mv "${i}" "`expr "${i}" : '0*\(.*\)'`"
    done
    

提交回复
热议问题