How to filter Todays File/Files from array of files and copy them to another folder?

Hi Dear, UiPath community
i have a folder containing Number of files created on different dates

i want filter today created files(which were 2) from this folder and copy those to another folder of my wish.

How to approach this Problem?

Hi @Bhagyaraj_Digumarthi1

Follow below:

  1. Assign activity:

    • To: filePaths
    • Value: {Array of file paths}
  2. Assign activity:

    • To: today
    • Value: DateTime.Now.Date
  3. For Each activity:

    • TypeArgument: String
    • Values: filePaths
  4. Assign activity:

    • To: fileCreationDate
    • Value: File.GetCreationTime(currentFilePath).Date
  5. If activity:

    • Condition: fileCreationDate = today
  6. Copy File activity:
    - Source: currentFilePath
    - Destination: {Destination folder path}

Hope it will helps!

Regards,

Hi @Bhagyaraj_Digumarthi1

Once you get all the file names in an array, you can use this expression to get the latest file (mostly created today):

latestFile = fileList.OrderByDescending(Function(x) New FileInfo(x).LastWriteTime).FirstOrDefault()

This will get you the first top file. You can move the file to a different folder & execute the same expression again, you will get another file as well.

Hope this helps,
Best Regards.

@Bhagyaraj_Digumarthi1 : Please find code for your reference
FiletFiles.zip (3.5 KB)
, Please let me know in case any issues.

1 Like

Hi @arjunshenoy i’m not moving the file i’m jst copying the file, so if i use this i will same file again and again.

is their any other way around? i might have number of files created on that same day.

@Bhagyaraj_Digumarthi1

To pick up the second file, you can copy the first obtained file, move it to a temporary folder, copy the second file & then move the first file back to its original location.

Hope this helps,
Best Regards.

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