How to read file name (only number yellow highlight)
I want number after text Charge_ and before _ as below.
I want output round 1 = 473 , round 2 = 594 , round 3 = 649
Please guide me about it.
How to read file name (only number yellow highlight)
I want number after text Charge_ and before _ as below.
I want output round 1 = 473 , round 2 = 594 , round 3 = 649
Please guide me about it.
@vinithareddyk123 What activity for use in uipath?
Hi @fairymemay,
You can use a for loop to get the file name first
For File in Directory.GetFiles(YOURPath,“*.pdf”)
Use the File.ToString as input to Matches activity and use the regex expression to extract the number : Charge_(?P<ItemNumber>\d+)_
Your variables will then be accessible in
YourRegexOutMatches(0).Groups(1).ToString
Hi @fairymemay
You can write inside assign activity also.
Use for each to loop through the files in folder using Directory.getFiles(“YourFolderPath”,“*pdf”)
and later passed the item value to the regex expression as shown below.
Output:
Hi
Hope these steps would help you resolve this
—use a assign activity like this
Arr_filepath = Directory.GetFiles(“your folder path”,”*.pdf”)
Where arr_filepath is a array fo string variable
—now use a FOR EACH loop and pass the above variable as input and change the type argument as string
—inside the loop use a writeline activity like this
Split(Split(item,”“)(1).ToString,”“)(0).ToString
This will give the value you want in output panel
Here we are trying to split the text from first underscore and again splitting that with first underscore
First we will get this
473_069990
Next will get this
473
Both is done in a single expression
Cheers @fairymemay
@fairymemay - please check this post…
Here instead of change it to (1) …
StrArrayNum = Directory.GetFiles("YourFolderName","*.pdf").select(Function(x) path.GetFileNameWithoutExtension(x).split("_"c)(1)).toarray
Here StrArrayNum is of variable type String Array
Another option would be to Split on _ and get element 1.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.