Skip to content

Instantly share code, notes, and snippets.

@AkBKukU
Created June 4, 2022 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AkBKukU/ae72b0f8e3d60c80d857014bef81cea3 to your computer and use it in GitHub Desktop.
Save AkBKukU/ae72b0f8e3d60c80d857014bef81cea3 to your computer and use it in GitHub Desktop.
#!/bin/bash
counter=0
files=(*)
count=${#files[@]}
dir=0
for file in *
do
echo "File: `printf %03d $counter`-$file"
if [[ "$1" == "--apply" ]]
then
mv $file "`printf %03d $counter`-$file"
fi
if [[ "$dir" == 0 ]]
then
counter=$((counter+2))
else
counter=$((counter-2))
fi
if [[ "$((counter+1))" -gt "$((count))" ]]
then
counter=$((counter-1))
dir=1
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment