Skip to content

Instantly share code, notes, and snippets.

@icecreammatt
Last active August 29, 2015 14:09
Show Gist options
  • Save icecreammatt/4011270ed7a9ff6c8d26 to your computer and use it in GitHub Desktop.
Save icecreammatt/4011270ed7a9ff6c8d26 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Pad a list of images with 0's
# %03d means pad with 3 0's, 4.jpg renamed to 004.jpg
images=$(ls *.jpg)
for image in $images;
do
echo $image
value=$(echo $image | sed 's/.jpg//')
padded=$(printf "%03d" $value)
echo $padded.jpg
mv $image $padded.jpg
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment