#!/usr/bin/perl -w -d # Rename dates to yy-mm-dd # Initial format: OO TM Meeting minutes m-d-y (n) chomp(@ARGV = ) unless @ARGV; @files=glob($ARGV[0]); for (@files) { $was = $_; ($a,$ext)=/(.*)\.(\S+)$/; $a=~s/\s*\(\d+\)$//; # get rid of (1), (2), etc. ($begin,$m,$d,$y)=$a=~/(.+?)\s*(\d+)-(\d+)-(\d+)/; #grab the date info $result=sprintf("%s %02d-%02d-%02d\.%s",$begin,$y,$m,$d,$ext); print $result," | ",$was,"\n"; `rename \"$was\" \"$result\"`; }