Move File if Not Today's File

Hello Team,

If we have a list of files in Local Folder Path

How do we check in it if the file is not today’s then move to a different folder path

Thanks Team in advance

@NISHITHA

can you share sample file name how they are in that shared folder

Hii @Shiva_Nikhil ,

Sure

Example

If we have InputData FolderPath in Which

If the Files Present Have date Modified as Today’s date then they should not be moved

But incase

The Date Modified is Not Today’s (Example 3/12/2024)
Then Move to OutPut Data Folder Path

1 Like

@NISHITHA

Can you try this once

System.IO.Directory.GetFiles("Provide your folder path").Where(Function(f) New System.IO.FileInfo(f).CreationTime.Date < DateTime.Today).ToArray()

Hi @NISHITHA

You can use the below expression to get the list of file paths that are not created today,

- Assign -> List_Files = System.IO.Directory.GetFiles("Folder Path").AsEnumerable.where(Function(X) Not(System.IO.File.GetCreationTime(X).Equals(DateTime.Now))).tolist()

→ Use For each activity to iterate through each file in List_Files.
→ Inside for each insert Move file activity to move the each file to other folder.

Check the below workflow for better understanding,

Hope it helps!!

Hi,

Try as below:-

Assign currentDate = DateTime.Now.ToString(“MM/dd/yyyy”)

For Each file in Directory.GetFiles(InputDataFolderPath)
If File.GetLastWriteTime(file).ToString(“MM/dd/yyyy”) <> currentDate
Move File: Source = file, Destination = OutputDataFolderPath
Else

Thanks

Thanks @mkankatala for sharing

Is List of String Being Used in

List_Files Assign activity

Thanks @Shiva_Nikhil and @Jayesh_678 for sharing Reference

1 Like

Yes you have to use List of String datatype to the List_Files Variable… @NISHITHA