Skip to content

Instantly share code, notes, and snippets.

@mikesorae
Last active December 24, 2015 13:48
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 mikesorae/6807406 to your computer and use it in GitHub Desktop.
Save mikesorae/6807406 to your computer and use it in GitHub Desktop.
zero padding one-liner for underscore separated file name e.g. foo_1_bar.jpg foo_2_bar.jpg ↓ foo_001_bar.jpg foo_002_bar.jpg
ls | ruby -n -e '/([^_]*_)([^_]*)(_.*)/ =~ $_; puts "%s%03d%s"%[$1, $2, $3]'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment