I have a script that will accept user directory paths as input, and then output the size of every user's folder. Everything was working fine until the script hit a user that had a folder with over 20 identical subfolders. The folder names were identical with 8 characters and in caps: "STUFFCOM". When the script hit this, it ended and reported the following: Can't cd to \\server\d$\dept\users\r_johnson/STUFFCOM/STUFFCOM/STUFFCOM/STUFFCOM/STUFFCOM/STUFFCOM/STUFFCOM/STUFFCOM/STUFFCOM/STUFFCOM/STUFFCOM/STUFFCOM/STUFFCOM/STUFFCOM/STUFFCOM/STUFFCOM/STUFFCOM/STUFFCOM/STUFFCOM/STUFFCOM/STUFFCOM/STUFFCOM../../../../../../../../../../../../../../../../../../../../../.. at C:/Perl/lib/File/Find.pm line 535, <IN> line 1. I have figured a way around this, and that was to reduce the number of subfolders to 19. My question is why would I be receiving this error, and why does reducing the number of subfolders fix the problem? Here is the code for my program:

#!/usr/bin/perl use File::Find; use strict; use Time::localtime; use File::Spec; my $cur = File::Spec->curdir; my $up = File::Spec->updir; my $dirtot; my ($dir, @parts, $error, $starttime, $runtime, $endtime, $runmin, $ye +ar, $month, $day, $tm, $date,$rootdir,$userdir,$slash); $tm = localtime; $year = $tm->year+1900; $month = $tm->mon+1; $day = $tm->mday; $date = "$month-$day-$year"; $slash = "//"; #Opens the input and output files open(IN, "< websize_input.txt") or die("Couldn't open websize_input.tx +t\n"); open(OUT, "> websize_out.csv") or die("Couldn't open websize_output.cs +v\n"); #Separates the newline delimited rows chomp ( @parts = <IN> ); #Used to calculate how long the program took to run $starttime = (time); #Prints headings print OUT "Path,User,MB,Date,Error?\n"; #Displays total for subdirectories foreach my $start (@parts) { my @dirs = &find_subdirs($start); foreach my $dir (@dirs) { ($rootdir,$userdir) = split /$slash/,$dir; print "\tWalking $dir\n"; my $total = 0; find sub { $total += -s }, $dir; $dirtot = $dirtot + $total; #Used for determining tota +l directory size $total = ($total / 1024) / 1024; #Converts to MB $total = sprintf("%0.2f", $total); #Formats output to 2 de +cimals print OUT"$rootdir,$userdir,$total,$date,$!\n"; } $dirtot = ($dirtot / 1024) / 1024; #Converts to MB $dirtot = sprintf("%0.2f", $dirtot); #Formats total to 2 deci +mals print STDERR "$start: No subdirectories\n" unless @dirs; } print "\nOutput created."; sub find_subdirs { my $start = shift; unless(opendir(D, $start)) { warn "$start: $!\n"; next; } my @dirs = map { -d "$start/$_" && !-l "$start/$_" && $_ ne $cur && $_ ne $up ? "$start//$_" : () } readdir(D); closedir(D); @dirs; }


I'd appreciate any help you can provide!

In reply to File::Find subdirectory limit? by Concept99

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.