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 7908365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:54:08+00:00 2026-06-03T11:54:08+00:00

I got the following script for loading about hundred thousand .doc files and ran

  • 0

I got the following script for loading about hundred thousand .doc files and ran a program on them. Based on the output, files are grouped in to folders. I tested the script on a local directory with few files, and it works as expected.

But when loading from the large corpus of files, the script prints “Loading Files….” and stays there. It seems the script is waiting till it loads all the files from the corpus. If this is the case, is there a way to load and process one file at a time?

It would be great if you could comment on efficiency aspect too.

$path = "\\Storage\100kCorpus"
$filter = "*.doc"
$count = 0
Write-Host "Loading files....";
$files = @(get-childitem -recurse -path $path -filter $filter)
Write-Host "files loaded";
foreach ($file in $files) {
    $count ++
    Write-Host "$file.FullName";
    $out = & "D:\Test\doc\Verify.exe" /i:$file.FullName 
    $failed_file_location="D:\Test\doc\2875555\$out";
    if (($out -ne "passed") -and !(Test-Path -path $failed_file_location )){
        [IO.Directory]::CreateDirectory($failed_file_location)
        Copy-Item $file $failed_file_location
    }
}

Write-Host "There are $count files with the pattern $filer in folder $path"
  • 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-06-03T11:54:11+00:00Added an answer on June 3, 2026 at 11:54 am

    It will work the way you want if you pipe the output of get-childitem, instead of saving it to an array, i.e.

    get-childitem -recurse -path $path -filter $filter | % {
        $file = $_
        $count ++
        # etc ...
    }
    

    Note that $file = $_ is just so you don’t have to modify your script too much.

    Efficiency-wise I don’t have much to say, except that in this way you are also avoiding to store all the file objects into an array ($files), so this version is at least avoiding an unnecessary operation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i've got the following problem. Downloaded one script, and it's loading all images from
I've got the following jsp page and I'm using struts2-jquery-plugin-3.1.1 <script type=text/javascript> function openDialog()
I've got the following code: <code><html> <body><br> <script type=text/javascript src=http://code.jquery.com/jquery-1.4.2.min.js /> <script type=text/javascript> alert(debug);
I've got the following code: <script type=text/javascript> $(function(){ $(#AddMaps).submit(function(){ var $form = $('#AddMaps'); $.ajax({
So, I got the following script, this one updates the twitter status without Oauth:
I've got the following login script.. <?php $name = $_POST[name]; $password = $_POST[password]; $query
I've got the following script, but addClass is not called on the li spect
I've got the following JavaScript script for generating a 2D maze: /* * 3
I got the following traceback in my setup script: Exception in Tkinter callback Traceback
I've got the following in my <head> section: <script type=text/javascript> $(function(){ $(h5).live(click, function(){ alert($(this).tmplItem());

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.