Rename files to concesutive numbers


/ Published in: Bash
Save to your folder(s)

Found on the Ubuntu forum: http://ubuntuforums.org/showthread.php?t=1355021

Renames files to 0001.jpg, 0002,jpg etc

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.