How to move files with the same format from a folder to another one? I got the problem with the Expressionwith

How to move files with the same format from a folder to another one? I got the problem with Expression!

I try to move files with format " CustomerName_Report_DDMMYYYY.xlsx/.pdf to a same folder “YYYY” and the other not have the same format to another file!

I do not know how to sort

Sorry this is not clear. Could you please elaborate?

This is my task! I have problem to write the expression to sort files with same format and move to one folder!

Hi @Nguy_n_Th_y

Regarding the files

First

Check the file name with below regular expression

\w+REPORT\d{2}/\d{2}/\d{4}
CASE 1

If the filename is matching with above regular expression, then it implies that ur filename has pattern CostumerName_REPORT_DDMMYYYY

then, u had to do the following things :

Use Path exist to check whether the folder with year specified in file exist

If it is true , then use move file activitiy to move the file to the specified folder

If it is false, first create the folder and then move it

CASE 2

If the filename is not in the specified format then , use create folder to create a folder with today’s date and then move it to the that folder

This is the logic u can apply

Regards

Nived N :robot::robot:

Happy Automation :relaxed::relaxed::relaxed:

I guess, it should be \w+_Report_\d{2}\d{2}\d{4}

@Nguy_n_Th_y - For the below portion…

image

  1. Path.getfilenamewithoutextension(File) - Which will give you “CustomerName_Report_11032021”
  2. Use Assign= StrYear = Regex.matches( Path.getfilenamewithoutextension(File), “\w+ _ Report _ \d{2}\d{2}(\d{4})”)(0).groups(1).tostring (Remove additional spaces from the pattern…)

  1. Take that year variable and check using folder exists…if not create one and move the file…
2 Likes

Hi @Nguy_n_Th_y …I have completed this workflow…I would suggest to give it a try based on the above inputs…if you get stuck please feel free to reach …

I will share the sample workflow …

1 Like

Hi @prasath17

Thanks for correction regarding regex pattern

Regards

Nived N :robot::robot:

1 Like