Move file by condition

In the input folder, the following files are stored:

  • ABC_TTT_20250901.txt
  • PAA_20250901.txt
  • PCA_20250901.txt
  • PPM20250901.xlsx
  • PPM20250902.xlsx
  • ABC_TTT_20250904.txt
  • PAA_20250904.txt
  • PCA_20250904.txt
  • PPM20250904.xlsx

The requirement is to check for sets of files that share the same date suffix, specifically:

  • ABC_TTT_xxxxxxxx.txt
  • PAA_xxxxxxxx.txt
  • PCA_xxxxxxxx.txt
  • PPMxxxxxxxx.xlsx

If all four files with the same date exist, extract the date value, move these files to the current folder, perform further processing, and then continue checking the next available date.

Please guide me for solve it.
Thank you

@Stef_99

Here are steps you can follow

  1. First use assign with Directory.GetFiles("Folder","ABC_TTT_*") this gives list of files paths which exists for ABC_TTT
  2. Now loop on these files and extract the date value from the pathโ€ฆcurrentitem.split("ABC_TTT_").Last.Replace(".txt","") will give the date value
  3. Now use the date value to check if remaining files with the name and date exists uisng for each file or directory.getfiles..if all are present move the files else continue loop

cheers

1 Like

Hello @Stef_99 You can try this 1)Get files Using Directory.GetFiles("input").
2)For each file use Regex to extract the 8-digit.
3)Store files in a dictionary (key = date, value = list of files).
4)For each date, confirm all 4 required files (ABC_TTT, PAA, PCA, PPM).
5) If set is complete, use Move File to current folder.

Hope it helps you

cheers

1 Like

Hello @Stef_99

DateFilteration.zip (4.4 KB)

Try this flow

This solution will definitely work

Output will be

image

Each same data will be in One folder

Regards,
Rajesh Rane

1 Like

Here are the steps to solve

  1. List all files in input folder.
  2. Extract unique dates from filenames.
  3. Loop through each date.
  4. Check if all required files exist for that date.
  5. Move the files to the processing folder.
  6. Process the files.
  7. Continue with the next date.

Hope it works

Cheers!

1 Like

Hello @Stef_99

If my flow works for you kindly mark it as a solution .

Regards,
Rajesh Rane

1 Like

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