Skip to content

Instantly share code, notes, and snippets.

@marians
Created July 7, 2011 20:22
Show Gist options
  • Save marians/1070457 to your computer and use it in GitHub Desktop.
Save marians/1070457 to your computer and use it in GitHub Desktop.
Batch renaming files to create a numbered file sequence
#!/bin/bash
# Assuming that you have a number of
# PNGs in a folder pngs/, this script
# will rename them to a file sequence
# like 0001.png, 0002.png, ...
n=0
for f in pngs/*.png; do
n=`expr $n + 1`;
name=`printf "%04d" $n`.png;
mv $f pngs/$name
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment