开发者

Linux command line script to renumber files backward

开发者 https://www.devze.com 2022-12-29 10:06 出处:网络
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.jp

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

精彩评论

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