in reply to How to automate construction of directories?

It wasn't clear if "a client" is just a number, and if you need the three directories made for each of the 10,000 clients.

Also, do you always group together directories in chunks of ten? If the answer to all these is "yes", then something like this may do the trick:

my $chunk_size = 10; foreach my $chunk (0 .. 10_000 / $chunk_size) { my $start = $chunk * $chunk_size; my $end = $start + $chunk_size - 1; # I say "${start}" to keep it from being interpreted as $start_ mkdir "2005/${start}_$end" or die "can't mkdir: $!"; foreach my $client ($start .. $end) { mkdir "2005/${start}_$end/$client" or die "can't mkidir: $!"; foreach (qw/addendums current archive/) { mkdir "2005/${start}_$end/$client/$_" or die "can't mkidir +: $!"; } } }

(I didn't test this.)

Replies are listed 'Best First'.
Re^2: How to automate construction of directories?
by CountZero (Bishop) on Jan 05, 2005 at 21:52 UTC
    It might be a good idea to add leading zeroes to the numbers, so the file-system sorts the directories in a more legible way. You would rather like it to be
    • 2005/00000_00010
    • 2005/00010_00020
    • 2005/00020_00030
    • 2005/00030_00040
    • ...
    than
    • 2005/0_10
    • 2005/10_20
    • 2005/100_110
    • 2005/1000_1010
    • ...
    • 2005/20_30
    • 2005/200_210
    • 2005/2000_2010
    • ...

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

      It might :)

      But it wasn't specified, and the OP actually gave a contrary example.

      (Requirements are always the hard part!)