Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Dear Sirs,
I want to display the folder name and number of files in that folder in one line, using dos batch commands. Like this I want to display the details of all the sub folders.
Examaple of my display:
Folder 1 5 files
Folder 2 10 files
Folder 3 0 files
Folder 4 8 filesThanks & regards,
S V Ravindra Babu

here is the pseudocode:
for /d %%a in (*) do ( <nul set/p =Folder %%a dir/b/a-d "%%a"|find/c /v "" )

Dear Reno,
Thank you very much for your reply.
But, I am extremely sorry to say that my problem is not soved.
For example, I wanted the output like this.
Folder Name No. of files
Folder 1 5
Folder 2 10
Folder 3 0
Folder 4 8Therefore, request you to extend the courtesy and expand the solution further.
Regards,
Ravi

@echo off for /d %%a in (*) do ( <nul set/p =Folder %%a dir/b/a-d "%%a" 2>nul|find/c /v "" )Sample Output:
C:\batch>tes Folder bak1 0 Folder bak2 0 Folder bak3 0 Folder bak4 0 Folder bak5 0 Folder haha 0 Folder hahah 1 Folder hihi 1 Folder n 39 Folder new 90 Folder string 0 Folder tes 0 Folder tes string 0 Folder test2 2 Folder XYZ!errorlevel! 2 Folder XYZ0 2 Folder XYZ2009 3 Folder XYZ20090219 3

Dear Reno,
Thank you very much. Its working.
I shall be grateful, if you could kindly extend the same further.
Let me first explain my exact requirement.
I have 10 folders and under each folder there are PDF files, as detailed below.
Folder Name: 9781860947186
Files under the above folder.
1. 9781860947186_0001.pdf
2. 9781860947186_0002.pdf
3. 9781860947186_0003.pdf
4. 9781860947186_bmatter
5. 9781860947186_fmatter
6. 9781860947186_others0001.pdf
7. 9781860947186_others0002.pdfFolder Name General fmatter bmatter others
PDFs9781860947186 3 1 1 1
Folder Name: 9781860947187Files under the above folder.
1. 9781860947187_0001.pdf
2. 9781860947187_0002.pdf
3. 9781860947187_0003.pdf
4. 9781860947187_fmatterFolder Name General fmatter bmatter others
PDFs9781860947186 3 1 0 0
Likewise for all other folders.
This will help me save lot of time and avoid mistakes while doing the same manually.
Thanking you once again.
With kind regards,
Sinrerely yours,
Ravi

Dear Reno,
Or you may take in this way.
Assume that there are 4 folders and under each folder there are different files like PDF Files, DOC Files, XLS Files, JPEG Files etc., randomly.
I want to redirect the output to an Excel Spread Sheet as detailed below.
Folder PDF DOC XLS JPG
ABC 2 3 1 4
DEF 4 1 0 5
GHI 3 0 2 3
JKL 0 2 4 0When there are no files, it must display 0.
Thanking you in advance and looking forward the pleasure of receiving a suitable solution for my problem.
With kind regards,
Sincerely yours,
Ravi

yes, i understand what you are trying to achieve. and it would also be nice if you could at least TRY to solve the problem, rather than expect me to write the whole code for you.
and when you are stuck, you can post your partial code and tell us which part it doesn't work.
FYI, you can't redirect the output to Excel Spreadsheet, unless you know the binary structure of excel files.

Dear Reno,
Once again thanks for your advice.
Though I am strong in DOS, little week in Batch Programming, but quite interested. As such, I had tried my level maximum best on my own interest, but couldn't succeed much. I used to write small macros in Excel to meet my daily routine work.
Anyways, I append below my efforts.
Folder Name: 9781860947186
Files under the Folder:
9781860947186_0001
9781860947186_0002
9781860947186_0003
9781860947186_0004
9781860947186_0005
9781860947186_0006
9781860947186_0007
9781860947186_0008
9781860947186_0009
9781860947186_fmatter
9781860947186_bmatter
9781860947186_others_01
9781860947186_others_02
9781860947186_others_03 and so on.1st Code:
dir/s/a-d/b | find /i "*_0*.pdf" & find /i "*_f*.pdf" & find /i "*_b*.pdf" & find /i "*_o*.pdf" > 1.xls
2nd Code as separate commands:
dir /ad/b >1.xls
dir /s "*_0*.*" | find /i "file" >>1.xls
dir /s "*_f*.*" | find /i "file" >>1.xls
dir /s "*_b*.*" | find /i "file" >>1.xls
dir /s "*_o*.*" | find /i "file" >>1.xlsSecond one is somehow working fine, but when there are no files towards bmatter or others, it must show zero against the corresponding category, but skipping the entry.
"bmatter" and "others" are optional in a folder as given by the client, where remaining files are mandatory.
It will be also ideal, if the desired output can be acquired with VBA programming.
To be frank, I am very much interested in programming but unfortunately put up in some other line.
With kind regards,
Sincerely yours,
Ravi

![]() |
![]() |
![]() |

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