Move previous day folder to archive folder

Hi All,

I want to move previous day’s folder to archive folder . How do I put a condition check everytime so that it checks all old date’s folder except today’s folder and move to archive folder

Hi @marina.dutta

folders = Directory.GetDirectories("path\to\source\directory")
foldersToMove = folders.Where(Function(folder) Path.GetFileName(folder) <> DateTime.Now.ToString("yyyy-MM-dd")).ToArray()

For each activity - foldersToMove
Move Folder activity

Regards,

Hi @marina.dutta

Could you clarify if you want to move the previously created folders to the archive folder or the folder names contain dates?

If you want to process with the folder name share one of the folder name with us.

@mkankatala

I want to move previously created folders to archive folder

Okay follow the below steps… @dutta.marina

→ Use the for each activity and write the below Expression,

System.IO.Directory.GetDirectories("Give Parent Folder Path here").Where(Function(X) CDate(New System.IO.DirectoryInfo(X).CreationTime).Date<(DateTime.Today)).Select(Function(y) System.IO.Path.GetFullPath(y))

→ Output of For each activity is currentText.
→ Inside For each activity insert the Move file activity and give currentText in From field and give Archive folder path in To Field.

Check the below workflow for better understanding,

Hope it helps!!

1 Like

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