Posted By

Carolyne on 12/05/10


Bash files rename numbered mv

Versions (?)

Rename files to concesutive numbers

 / Published in: Bash

Found on the Ubuntu forum:

Renames files to 0001.jpg, 0002,jpg etc

You can insert a prefix here: "prefix-$j.jpg"

  1. i=1
  2. for file in *.jpg
  3. do
  4. j=$( printf "%04d" "$i" )
  5. mv "$file" "$j.jpg"
  6. (( i++ ))
  7. done

Report this snippet  

You need to login to post a comment.