Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
How do I rename a file to include the directory as part of the filename?

I have thousands of Bruce Springsteen MP3's on my PC. They are all from different live shows. They are setup in directories named for each show. However, the file names themselves do not have the artist or the concert as part of the file name.

For example, in the folder

/music/Springsteen/Springsteen - 1973-03-07 Max's Kansas City

I have several songs,

01 Mary Queen of Arkansas.mp3
02 Bishop Dance.mp3
...
...
08 Song to Orphans.mp3

Unfortunately the MP3 player I'm using only displays the file name in its playlist. Therefore identifying a particular song from a particular show is difficult. How can I rename the files to include the parent directory as part of the file name? I'm looking for a simple script that will let me do it.

Ideally my files would all be renamed like this :

Springsteen - 1973-03-07 Max's Kansas City - 01 Mary Queen of Arkansas.mp3
Springsteen - 1973-03-07 Max's Kansas City - 02 Bishop Dance.mp3
...
...
Springsteen - 1973-03-07 Max's Kansas City - 08 Song to Orphans.mp3

Can this be done?


In reply to Renaming Files by Anonymous Monk

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-04-19 22:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found