-1

I currently have a directory of files with date based names in the format mmddyy:


    nxd060815a.html
    nxd060915a.html
    nxd061015a.html

and would like to change file name format to yyyy-mm-dd:


    nxd2015-06-08a.html
    nxd2015-06-09a.html
    nxd2015-06-10a.html

How would I do this from the command line?

Any help is appreciated.

verbatim
  • 219
  • 2
  • 7

1 Answers1

1
ls | awk '{ system("mv " $0 " " substr($0,1,3) "20" substr($0,8,2) "-" substr($0,4,2) "-" substr($0,6,2) substr($0,10,6))}'

run the above from the dir the files are in. You should be able to figure out whats going on, so no other comment.

Jrican
  • 302
  • 3
  • 10