Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
And this is my FINAL results. I tested it on TWO LARGE folders and it worked great. And YES, I backed up first. :-)

I thank you Sooooooooo Much

-Regards -Ray
#!/usr/bin/perl # use POSIX qw/strftime/; # use strict; # use warnings; # use diagnostics; sub fixdir { my $dir = shift; opendir my $DH, $dir or die "Not Found....$dir: $!"; while (my $f = readdir $DH) { next if grep $_ eq $f, qw/. ../; fixdir("$dir/$f") if -d "$dir/$f"; (my $new = $f) =~ s/[^a-zA-Z0-9_.]/_/g; if ($new eq $f) { next; } while ( -e "$dir/$new") { $new .= "1"; } print STDERR "Renaming: $f -> $new\n"; rename "$dir/$f", "$dir/$new"; } } die "No command line arguments given!" unless @ARGV; my $nargs = @ARGV; print "Number of command line arguments is $nargs\n"; my $Do_Dir = $ARGV[0]; # print("ARG=", "$Do_Dir", "<<<<<<\n"); if (!$Do_Dir ) { print ("No Folder Name given!\n"); exit; } print( "The Folder Name is: ", "$Do_Dir", "\n" ); fixdir("$Do_Dir"); print "Done...\n"

In reply to Re^6: FINAL - Transforming File Name Characters by rfleisch
in thread Transforming File Name Characters by rfleisch

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others examining the Monastery: (5)
    As of 2018-05-25 11:24 GMT
    Find Nodes?
      Voting Booth?