Skip to content

Instantly share code, notes, and snippets.

@parallaxisjones
Created April 18, 2020 22:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save parallaxisjones/a040628fc73da883c7238c270ee6709d to your computer and use it in GitHub Desktop.
Save parallaxisjones/a040628fc73da883c7238c270ee6709d to your computer and use it in GitHub Desktop.
#! /usr/bin/env bash
function zero_pad () {
n=$1
file=$2
padding=`seq 1 $n | sed 's/.*/0/' | tr -d '\n'`
zeroPadded="$padding$file"
if test -f "$zeroPadded"; then
echo "$zeroPadded exist"
else
cp $file $zeroPadded
fi
}
while test $# -gt 0
do
if [ -n "$1" ] && [ "$1" -eq "$1" ] 2>/dev/null; then
count=$1
else
if test -f "$1"; then
zero_pad $count $(basename $1)
fi
fi
shift
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment