Linux shell script to add leading zeros to file names

后端 未结 10 1609
梦如初夏
梦如初夏 2020-12-04 06:43

I have a folder with about 1,700 files. They are all named like 1.txt or 1497.txt, etc. I would like to rename all the files so that all the filena

10条回答
  •  一生所求
    2020-12-04 07:40

    One-liner hint:

    while [ -f ./result/result`printf "%03d" $a`.txt ]; do a=$((a+1));done
    RESULT=result/result`printf "%03d" $a`.txt
    

提交回复
热议问题