Rename of a dynamic file

Hello
I have a process I am download excel file
This file get dynamic name like : SOD-TestCaseLog-2023-06-08_12-20-20.xlsx
I want to change the name of the file for example to : CartReport.xlsx
How can I do that please ?

Hi @mironb

Can you provide us some more file names, so that we can analyze which part of the file name is going to remain constant & which part changes?

Best Regards.

@arjunshenoy Hi
I just made a process that download test set from Test Manager of the UiPath so all the files are the same

image

@mironb

You can iterate through each currentFile through the list of fileNames & you can use the following expression to check for the static part of the file name. If it matches, then you can proceed with the renaming actions:

System.Text.RegularExpressions.Regex.IsMatch(currentFile.ToString,"^SOD-TestCaseLog-")

image

Hope this helps,
Best Regards.

@arjunshenoy
What is the “currentFile” ?
What to fill in the rename activity ?
image

@mironb

  1. Let’s say you are downloading all the files in a folder called ‘DownloadFolder’. You will be getting all the file names into an array variable called filesArray, like this:

image

  1. Once you have all the file names in the array variable, you start iterating through the array using a For Each loop, like this:

image

  1. In each iteration here, currentFile contains the name of the present file in the iteration. Then you check whether the file name starts with the static part ‘^SOD-TestCaseLog-’, like this:

image

  1. If the condition is matched (that means the currentFile starts with ‘^SOD-TestCaseLog-’), the control comes to the true block & the file renaming sequence takes place, like this:

image

Edit: Please find the sample workflow file for your reference-

Demo.xaml (10.2 KB)

Hope this helps,
Best Regards.

@arjunshenoy
Thank you very much

1 Like

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