On Wednesday, 6 September 2017 at 10:58:25 UTC, Azi Hassan wrote:
On Wednesday, 6 September 2017 at 08:10:35 UTC, Vino.B wrote:
in the next line of the code i say to list only folders that are greater than 10 Mb but this now is listing all folder (folder whose size is less than 10 MB are getting listed, not sure why.

Is the size in GB ? If so, then subdirTotalGB = (subdirTotal/1024/1024); needs to become subdirTotalGB = (subdirTotal/1024/1024/1024); for it to take effect. But do correct me if I'm wrong, I still haven't had my morning coffee.

Hi Azi,

Your are correct, i tried to implement the fold in a separate small program as below, but not able to get the the required output, when you execute the below program the output you get is as below

Output:
[31460]
[31460, 1344448]
[31460, 1344448, 2277663]
[31460, 1344448, 2277663, 2277663]
[31460, 1344448, 2277663, 2277663, 31460]

Setup:

C:\\Temp\\TEST1\\BACKUP : This has 2 folder and 2 files in each folder C:\\Temp\\TEST2\\EXPORT : This has 2 folder and 2 files in one folder and 1 file in another folder

Total files : 5

Required output:
[31460, 1344448] - Array 1 for the FS C:\\Temp\\TEST1\\BACKUP
[2277663, 2277663, 31460] - Array 2 for the C:\\Temp\\TEST2\\EXPORT

import std.algorithm: filter, map, fold;
import std.parallelism: parallel;
import std.file: SpanMode, dirEntries, isDir;
import std.stdio: writeln;
import std.typecons: tuple;
import std.path: globMatch;
import std.array;
void main () {
        ulong[] Alternate;
string[] Filesys = ["C:\\Temp\\TEST1\\BACKUP", "C:\\Temp\\TEST2\\EXPORT"];
        foreach(FFs; Filesys)
                {
auto dFiles = dirEntries(FFs, SpanMode.shallow).filter!(a => a.isDir).map!(a => tuple(a.name, a.size)).array;
                        foreach (d; dFiles) {
auto SdFiles = dirEntries(join(["\\\\?\\", d[0]]), SpanMode.depth).map!(a => tuple(a.size)).array;
                                                                foreach (f; 
parallel(SdFiles,1)) {
                                                                Alternate ~= 
f[0]; writeln(Alternate);
                                                                                
                                                }
                                                                }
                }
}

From,
Vino.B

Reply via email to