Computing.Net > Forums > Programming > Count Files across multiple directories

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Count Files across multiple directories

Reply to Message Icon

Name: artod4789
Date: May 19, 2009 at 12:38:37 Pacific
OS: Windows
Subcategory: Batch
Comment:

I'm trying to come up with a bat file to count the amount of files of a certain name and output it to a certain file. I can do that through:

dir /a /s d:\dir\ex20090518.log | find "" /c /v >count.txt

However, I want to do this through multiple directories at once. So basically, I want this:

dir /a /s d:\dir\*\*\*\ex20090518.log | find "" /c /v >count.txt

Any thoughts on how to do this?

Thanks!



Sponsored Link
Ads by Google

Response Number 1
Name: ghostdog
Date: May 19, 2009 at 17:50:17 Pacific
Reply:

/s option of dir enables you to recurse directories already...


0

Response Number 2
Name: artod4789
Date: May 20, 2009 at 06:44:36 Pacific
Reply:

Then I don't get why it is not working. I know those files exist in those locations. So any thoughts why it doesn't work? I'm getting a "The filename, directory name, or volumen label syntax is incorrect" error. Not sure how that could be when I know the file with that name exists, the directory structure is there and the volume label is fine.

Any other thoughts?


0

Response Number 3
Name: artod4789
Date: May 20, 2009 at 06:53:32 Pacific
Reply:

I've gone back and done a static test where I filled in the *'s with actual directory names and it works fine. But the moment I put in an asterisk, it fails.


0

Response Number 4
Name: klint
Date: May 20, 2009 at 09:20:14 Pacific
Reply:

Don't use an asterisk, just name the top-level directory where you want it to start searching downwards.


0

Response Number 5
Name: artod4789
Date: May 20, 2009 at 09:56:33 Pacific
Reply:

So then how would that work? Like this?

dir /a /s d:\dir\ | find "" /c /v >count.txt

And how would I specify a particular file name? Basically I would be looking for fileA.log and not fileB.log or any others.

Thanks for all of the help!


0

Related Posts

See More



Response Number 6
Name: artod4789
Date: May 20, 2009 at 10:01:18 Pacific
Reply:

Well, I found it!!!

dir /a /s d:\dir |find "fileA.log" /c > count.txt

Works perfectly!!! Thank you all so much for your help!!!!!


0

Sponsored Link
Ads by Google
Reply to Message Icon

My Brother's Laptop Won't... batch file - reading from...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Count Files across multiple directories

Count files in a directory www.computing.net/answers/programming/count-files-in-a-directory/12308.html

counting files in sub directories www.computing.net/answers/programming/counting-files-in-sub-directories/16810.html

batch to count files in DIR then send email www.computing.net/answers/programming/batch-to-count-files-in-dir-then-send-email/19628.html