Hello again, wise monks!

After reading carefully the recommendations you made in my previous question (mkdir in loop - overwrite danger? - http://www.perlmonks.org/?node_id=1150970) I decided to use make_path and a different approach. And at this point let me thank you for taking the time to reply in that question and for introducing make_path to me.

So my new plan is the following. Instead of looping through my files and matching their filenames in order to use mkdir and create the directories, I decided to use make_path in order to build the directory tree first, and then use another script to process my files and redistribute them.

I just need a bit of guidance using make_path. Let me describe what I want to do in the end so that you can tell me if it's doable by make_path. I have 150 different folders that each one of them needs to have 100 subfolders. The names of both main folders and subfolders are specific. The main folders' names are like AB0001 up to AB0030, BC0001 up to BC0050 and a couple more similar patterns of the same logic. The subfolders need to every time be S00001 up to S00100.

Is this somehow doable with make_path? I am kind of figuring out the subfolders bit as it seems easier - it's always an "S" in the beginning and I need a counter and I need to specify that the name always needs to be 6 characters long. I hope I'll be able to write that. What's confusing me is the main folders bit. Can I do the same again? Can I say that "I want 30 folders, from AB0001 up to AB0030; also 50 folders, from BC0001 up to BC0050" and so on?

Obviously I don't expect ready code, just maybe some resources and guidance until I manage to write something that runs and can be shared here and corrected. This page http://perldoc.perl.org/File/Path.html didn't help me much, it is a bit confusing, also unfortunately my two perl books don't mention make_path as they're a bit old :( That's why I'm kind of lost on how to begin.

Thank you so much all, your help is immensely appreciated.


In reply to make_path for creating directory tree by fasoli

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.