Rename Excel File Wildcard

I have a BOT running that downloads an excel file in each loop that contains the word “export”.

Could be 123export.xlsx or abexport12.xlsx.

I am using the “Move File” activity within the loop but don’t believe I have the syntax correct for using a wildcard.

image

UiPath doesn’t like the ("E:\MyDownloads" + “*Export*.xlsx”) syntax and errors out.

Any suggestions? I appreciate your help.

Brett

Try using the attached workflow, which leverages the directory.enumerateFiles function (super helpful, I use all the time). Sand.xaml (6.2 KB)

To explain as it might be helpful for other bots:
Directory.EnumerateFiles allows you to use wildcards in the searchPattern parameter (the wildcards don’t work in the Move File parameters unfortunately).

1 Like

I get a “not a member of the System.IO.SearchOption” error when I try to enter that.

Sorry, edited my original post

1 Like

The workflow I attached iterates through every file that fits the criteria. If you know in advance there will only be one match, you can skip using the ‘For Each’ loop and simply put the below in the From parameter of ‘Move File’:

directory.enumerateFiles(“E:\My Downloads”, “*export*.xlsx”).first

1 Like

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