$ rename Usage: rename [-v] perlexpr [filenames]
Has anyone fine-tuned an expression to tidy up shell unfriendly filenames with rename? eg.
$ rename -v '$_=lc;s/[^\w.]+/_/g' * The Pogues - Beer, Beer, Beer (Irish drinking song).mp3 renamed as the +_pogues_beer_beer_beer_irish_drinking_song_.mp3
This is a start, but I'd prefer the ' - ' to become '-', there's the trailing "_", and there's no doubt more problem cases to be found. Before I started trying to DWIM for 98% of cases I figured someone else is bound to have been there before me.

Anyone solved this already..?

Thanks,


In reply to Clean filenames with /usr/bin/rename by bsb

Title:
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, details, 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, summary, 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.