Skip to content

Instantly share code, notes, and snippets.

@pioz
Created August 8, 2017 13:29
Show Gist options
  • Save pioz/1cd3855492662b9bfd3cf6fc836f50f0 to your computer and use it in GitHub Desktop.
Save pioz/1cd3855492662b9bfd3cf6fc836f50f0 to your computer and use it in GitHub Desktop.
Rename file in batch
ls * | cat -n | while read i f; do mv "$f" `printf "%04d.${f#*.}" "$i"`; done
ls * | cat -n | while read i f; do mv "$f" `printf "$(basename $f .${f#*.})_%04d.${f#*.}" "$i"`; done
https://stackoverflow.com/a/45569550/302005
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment