Create a gist now

Instantly share code, notes, and snippets.

One-liner that adds a 0 to filename's ranging from 1 to 9, when there are more than 9 files with numbers appended in their filename, thus fixing the ordering when listed
# Add this one-liner script to the PATH variable and have the power to count the files in a directory from anywhere in the command line
#NAME is the prefix that the files share in common
NAME=$1; ls -1 | grep -E ${NAME}[0-9]{1}\\. | sed -e 'p;s/\([0-9]\)/0\1/g' | xargs -n 2 mv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment