Skip to content

Instantly share code, notes, and snippets.

@maeharin
Last active December 11, 2015 07:59
Show Gist options
  • Save maeharin/4570471 to your computer and use it in GitHub Desktop.
Save maeharin/4570471 to your computer and use it in GitHub Desktop.
one liner / rename directory at current directory yyyymmdd -> yyyy_mm_dd / scan / sub
$ ls | ruby -nle '$_.scan(/\d{8}/) {|m| File.rename(m, m.sub(/(\d{4})(\d{2})(\d{2})/) {"#{$1}_#{$2}_#{$3}"})}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment