Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 872909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:51:16+00:00 2026-05-15T10:51:16+00:00

A directory exists with a total of 2,153,425 items (according to Windows folder Properties).

  • 0

A directory exists with a total of 2,153,425 items (according to Windows folder Properties). It contains .jpg and .gif image files located within a few subdirectories. The task was to move the images into a different location while querying each file’s name to retrieve some relevant info and store it elsewhere.

The script that used File::Find finished at 20462 files. Out of curiosity I wrote a tiny recursive function to count the items which returned a count of 1,734,802. I suppose the difference can be accounted for by the fact that it didn’t count folders, only files that passed the -f test.

The problem itself can be solved differently by querying for file names first instead of traversing the directory. I’m just wondering what could’ve caused File::Find to finish at a small fraction of all files.

The data is stored on an NTFS file system.

Here is the meat of the script; I don’t think including DBI stuff would be relevant since I reran the script with nothing but a counter in process_img() which returned the same number.

find(\&process_img, $path_from);

sub process_img {
    eval {
        return if ($_ eq "." or $_ eq "..");

        ## Omitted querying and composing new paths for brevity.

        make_path("$path_to\\img\\$dir_area\\$dir_address\\$type");
        copy($File::Find::name, "$path_to\\img\\$dir_area\\$dir_address\\$type\\$new_name");
    };
    if ($@) { print STDERR "eval barks: $@\n"; return }
}

EDIT:

eval barked a few times regarding BDI errors:

DBD::CSV::db do failed: Mismatched single quote before:
'INSERT INTO img_info (path, type, floorplan, legacy_id)
        VALUES (
            ?0?building?1?0?2?19867'
        )' at C:/perl/site/lib/SQL/Statement.pm line 77
[for Statement "
INSERT INTO img_info (path, type, floorplan, legacy_id)
        VALUES (
            'wal/15 Broad Street/building/nyc-Wall-St--South-St--Seaport-condo-elevator- building-52201501.jpg',
            'building',
            '0',
            '19867'
        )
"]

I assume that’s due to the double dash between ‘St’ and ‘South’. No errors of other nature were reported.

And here is another method I used to count files:

count_images($path_from);
sub count_images {
    my $path = shift;

    opendir my $images, $path or die "died opening $path";
    while (my $item = readdir $images) {
        next if $item eq '.' or $item eq '..';
        $img_counter++ && next if -f "$path/$item";
        count_images("$path/$item") if -d "$path/$item";
    }
    closedir $images or die "died closing $path";
}

print $img_counter;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T10:51:17+00:00Added an answer on May 15, 2026 at 10:51 am

    It could have run out of resources? (memory, file descriptors, etc…?).

    or it could have been some funky file name (easy to test by re-running again but removing 10 files – if it stops on exact same file, that filename is the culprit)

    If you can trace the memory footprint, that’d tell you if you have a memory leak (see recent SO question on memory leaks to help with that).

    And as Ether said, we could offer hopefully more than general investigative idea had you pasted in the code.

    UPDATE

    Based one your code:

    1. Please indicate whether eval barks anything to STDERR

    2. More importantly, any IO operations need to be error-checked. E.g.

      copy($something,$other)
          || die "Copy $something to $other died with error: $!\n"; # or print
      # Same for making the directory
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with using Directory.Exists() on a string that contains an accented
How do I check whether a directory exists using C++ and windows API?
My company's code base contains the following C# line: bool pathExists = Directory.Exists(path); At
How to check if a folder (directory) exists in Cocoa using Objective-C?
Possible Duplicate: Check synchronously if file/directory exists in Node.js For example, i have a
The problem: I need to ensure that a particular directory hierarchy exists in the
I'm getting the filenotfoundexception on my apps directory but my directory clearly exists. I'm
DirectoryInfo dir=new DirectoryInfo(path); if (!dir.Exists) { Directory.CreateDirectory(path); File.Create(path + \\file.xml); StreamWriter sw =new StreamWriter(path
First look at this url: https://stackoverflow.com/questions/tagged/xoxoxo/ This directory does not exists but somehow stackoverflow
I want to know whether or not a directory exists. If not, I would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.