ArifS has asked for the wisdom of the Perl Monks concerning the following question:

I would like to replace a bunch of filenames from- "MY.switch._Org.1st.txt" "router.-2nd.Org.MY.txt" "3rd.switchmy-org.txt" to, something like as following with all uppercase- "1ST.SWITCH.MY.ORG.TXT" "2ND.ROUTER.MY.ORG.TXT" "3RD.SWITCH.MY.ORG.TXT" Any suggestion will be greatly appreciated.....

Replies are listed 'Best First'.
Re: Rename filenames in perl using regex
by LanX (Saint) on Aug 29, 2014 at 14:54 UTC
      I have something like the following so far to go thru the cleanup as I don't want any _or-.
      print "$file\n";

      $file =~ tr/_\t\r\n;:/ /;
      $file =~ tr/-\t\r\n;:/ /;
      $file =~ s/\s+/ /g;
      $file =~ s/MY./my/;
      $file =~ s/my./my/;
      print "$file\n";

      Now I am trying to figure out how to match a pattern like if it has '.my' or '.MYc' take '.MY' and place it in 3rd octet, and if it has any # like 1st, .2nd, or .4th then move that infront of the line etc.
Re: Rename filenames in perl using regex
by hippo (Archbishop) on Aug 29, 2014 at 16:24 UTC
      you are the best.... Thank you very much.
Re: Rename filenames in perl using regex
by GotToBTru (Prior) on Aug 29, 2014 at 14:44 UTC

    What have you tried so far?

    1 Peter 4:10