Skip to content

Instantly share code, notes, and snippets.

@psiborg
Last active September 20, 2021 19:56
Show Gist options
  • Select an option

  • Save psiborg/0290732d13061dda046e5b4685b67915 to your computer and use it in GitHub Desktop.

Select an option

Save psiborg/0290732d13061dda046e5b4685b67915 to your computer and use it in GitHub Desktop.
Sequentially rename jpg files in a folder
#!/bin/bash
a=1
for i in *.jpg; do
new=$(printf "$1-%04d.jpg" "$a") #04 pad to length of 4
mv -i -- "$i" "$new"
let a=a+1
done

Usage:

cd {folder_with_jpgs}
~/ren.sh {yyyymmdd}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment