开发者

Linux command line script to renumber files backward

I have JPG files numbered 3006-3057 that I would like to reverse number. I would be content renaming them by adding a backwards number count to the beginning of the name: img_3006.jpg > 99_img_3006.jpg and img_3057.jpg > 48_img_3057.jpg.开发者_如何学Python


basenumber=9999
for file in *.jpg
do
  base="${file%.*}"
  filenumber="${base#*_}"
  mv "$file" "$((basenumber-filenumber))_$file"
done
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜