What it will not do is tell you if more than one directory has exactly the same size.
The flaw in your task description that you aren't aware of, is that by not giving exact details of the folder names and range of characters sets being used, and the files and file attributes, nobody can tell you with certainty if it will work in your situation.
It should work with 30,000 folders in a directory - but you are probably going to get more than one folder with the same filesize, and that could be the smallest filesize.
Ok, let me explain the entire task in detail and see if perhaps there is a better way of doing all of this:
I have a directory with 33,359 RAW files. These range from the smallest (34 bytes) to the largest (7,508,609 bytes).
An executable program that I have has 9 possible compression options to process one of these RAW files. The options are:
c1
c2
c3
c4
c5
c6
c7
c8
c9
When any one of those options is used with a RAW file, 2 output files are created.
00001.rif
00001.hup
The command-line syntax would be:
rawcomp c1 00001.raw 00001.rif 00001.hup
In every case, the result is different--That is, for 00001.raw, c9 produces the smallest set of files (rif + hup). But for 00002.raw, c5 is the optimal option.
So what I have been doing is creating a set of directories for each RAW file and subdirectories for each rawcomp option (c1-c9):
00001
1
2
...
9
00002
1
2
...
9
The following code is used for this:
FOR %%b IN (temp\*.raw) DO mkdir temp\%%~nb
FOR /D %%a IN (temp\*) DO mkdir %%a\1,%%a\2,%%a\3,%%a\4,%%a\5,%%a\6,%%a\7,%%a\8,%%a\9
Then once all directories are created, the following is executed next on the batch file:
FOR %%l IN (1 2 3 4 5 6 7 8 9) DO FOR %%a IN (temp\*.raw) DO rawcomp.exe c%%l %%a temp\%%~na\%%l\%%l.hup temp\%%~na\%%l\%%l.rif
After that process is completed, then the code I was so generously provided here is executed with a separate batch file.
So there it is...This is the entire process. If needed, I can provide every individual filesize for every individual RAW file.
So is the way I am attempting to go about this the most ideal/efficient/optimal? Is Should the code provided here work perfectly in this situation?
Any and all help will be greatly appreciated as usual guys!
EDIT: One quick important note: Every option (c1-c9) are different compression levels meaning that the result is always smaller than the original RAW. So in the case of the 34 byte RAW file, all 9 files will be smaller. So when the step comes to identify the smallest directory and delete the others, it will be dealing with extremely small directories/files.