Hi All,

I have written a small program to just list the directories, but when i run the program each time i am getting different output, hence request you help, below is the code

Program:
import std.file: dirEntries, isFile, SpanMode, remove;
import std.stdio: writefln;
import std.algorithm: filter;
import std.parallelism: parallel;
import std.array: array;
import std.datetime;

auto AgedDirlst = [ "C:\\Temp\\TEAM", "C:\\Temp\\PROD_TEAM", "C:\\Temp\\BACKUP", "C:\\Temp\\EXPORT", "C:\\Temp\\sapnas3\\BACKUP", "C:\\Temp\\EXPORT"];


void AgedDir (string[] Dirlist)
{
 for (auto i = 0; i < Dirlist.length; ++i)
     {
auto dFiles = dirEntries(Dirlist[i], SpanMode.shallow).filter!(a => a.isDir);
          foreach (d; parallel(dFiles , 1))
                  {
                            writefln("%-63s %.20s", d, 
d.timeCreated().toSimpleString);
                          }
         }
}

void main ()
{
 AgedDir(AgedDirlst);
}

If i replace the line(.isDir to .isFile) "auto dFiles = dirEntries(Dirlist[i], SpanMode.shallow).filter!(a => a.isDir)" to auto dFiles = dirEntries(Dirlist[i], SpanMode.shallow).filter!(a => a.isFile), then is it working perfectly.

From,
Vino.B
Output
C:\Users\Admin\Desktop\Script\D>rdmd AgedDir.d
C:\Temp\TEAM\DIR1 2017-Aug-16 18:49:21 C:\Temp\TEAM\DIR1 2017-Aug-16 18:49:21 C:\Temp\TEAM\DND1 2017-Jun-30 21:02:09 C:\Temp\TEAM\DIR2 2017-Jun-29 23:21:36 C:\Temp\TEAM\DND5 2017-Jun-30 23:49:24 C:\Temp\PROD_TEAM\dir1 2017-Jun-30 05:38:05 C:\Temp\PROD_TEAM\dir1 2017-Jun-30 05:38:05 C:\Temp\PROD_TEAM\dir2 2017-Jun-30 05:38:05 C:\Temp\PROD_TEAM\DND1 2017-Jun-30 21:08:32

C:\Users\Admin\Desktop\Script\D>rdmd AgedDir.d
C:\Temp\TEAM\DIR1 2017-Aug-16 18:49:21 C:\Temp\TEAM\DIR2 2017-Jun-29 23:21:36 C:\Temp\TEAM\DND1 2017-Jun-30 21:02:09 C:\Temp\TEAM\DND5 2017-Jun-30 23:49:24 C:\Temp\PROD_TEAM\dir1 2017-Jun-30 05:38:05 C:\Temp\PROD_TEAM\dir1 2017-Jun-30 05:38:05 C:\Temp\PROD_TEAM\dir2 2017-Jun-30 05:38:05 C:\Temp\PROD_TEAM\DND1 2017-Jun-30 21:08:32

C:\Users\Admin\Desktop\Script\D>rdmd AgedDir.d
C:\Temp\TEAM\DND1 2017-Jun-30 21:02:09 C:\Temp\TEAM\DIR1 2017-Aug-16 18:49:21 C:\Temp\TEAM\DIR2 2017-Jun-29 23:21:36 C:\Temp\TEAM\DND5 2017-Jun-30 23:49:24 C:\Temp\PROD_TEAM\dir1 2017-Jun-30 05:38:05_TEAM\dir2 C:\Temp\PROD_TEAM\dir1 2017-Jun-30 05:38:05_TEAM\dir2
                  2017-Jun-30 05:38:05
C:\Temp\PROD_TEAM\DND1 2017-Jun-30 21:08:32

C:\Users\Admin\Desktop\Script\D>rdmd AgedDir.d
C:\Temp\TEAM\DIR1 2017-Aug-16 18:49:21 C:\Temp\TEAM\DIR1 2017-Aug-16 18:49:21 C:\Temp\TEAM\DND1 2017-Jun-30 21:02:09 C:\Temp\TEAM\DIR2 C:\Temp\TEAM\DND5 2017-Jun-30 23:49:24 C:\Temp\TEAM\DIR2 C:\Temp\TEAM\DND5 2017-Jun-30 23:49:24
                    2017-Jun-29 23:21:36
C:\Temp\PROD_TEAM\dir1 2017-Jun-30 05:38:05 C:\Temp\PROD_TEAM\dir1 2017-Jun-30 05:38:05 C:\Temp\PROD_TEAM\dir2 2017-Jun-30 05:38:05 C:\Temp\PROD_TEAM\DND1 2017-Jun-30 21:08:32

Reply via email to