Folder Creation Date Check

I have folders created with date in my drive . I need to check if the folder creation date is less than than today’s date in format(05-Sep-2024)? How can I check that ?

need to compare 22-Aug-2024 is less than 05-Sep-2024

@marina.dutta,

Use O365 integration or Scope and use Get File/Folder activity to get the desired Folder.

It will return you DriveItem.
You can get the creation time by driveItemVariable.Creationtime

Compare it with If condition.

Thanks,
Ashok :slight_smile:

@ashokkarale

I am trying to use the below expression, but not getting any output

System.IO.Directory.GetDirectories(folders).Where(Function(X) CDate(New System.IO.DirectoryInfo(X).CreationTime).Date.ToString(“dd-MM-yyyy”)<(DateTime.Now.ToString(“dd-MM-yyyy”))).Select(Function(y) System.IO.Path.GetFullPath(y))

Hi @marina.dutta

Can you try this

System.IO.Directory.GetDirectories(folders).Where(Function(X) New System.IO.DirectoryInfo(X).CreationTime.Date < DateTime.Now.Date).Select(Function(y) System.IO.Path.GetFullPath(y))

Regards,

@lrtetala

my system date is of format 09/05/2024

and file date 21-Aug-2024. actually I want to move older folder date to archive folder except folders which are created today

Hello @marina.dutta

To get the desired date formate for comparison, you can define the date like this:

Now.ToString(dd-mmm-yyyy)

This will return 05-Sep-2024 for today.

Regards
Soren

@marina.dutta

Try this way

1st If Condition:

System.Text.RegularExpressions.Regex.IsMatch(System.IO.Path.GetFileNameWithoutExtension(CurrentFolder.ToString), "\d{2}-[A-Za-z]{3}-\d{4}")

2nd If Condition:

DateTime.ParseExact(System.Text.RegularExpressions.Regex.Match(System.IO.Path.GetFileNameWithoutExtension(CurrentFolder.ToString), "\d{2}-[A-Za-z]{3}-\d{4}").Value, "dd-MMM-yyyy", System.Globalization.CultureInfo.InvariantCulture) < DateTime.Now

Regards,

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.