How to Get the date from an Excel File Name

I just need to know how to get the date from the file name and replace it with current date.
ABC 12-29-2022.xlsx (8.1 KB)
Here is the file name and I need to replace the date with current date.
Please can anyone Help??

@Kunal_Jain

Use copy file and then give the new name as below

Say the filename is in variable var1 then

System.text.regularexpressions.regex.Replace(var1,"\d{2}-\d{2}-\d{4}",Now.ToString("MM-dd-yyyy"))

Cheers

I just need an expression for using it in rename file
Because I am using rename file option for the same

@Kunal_Jain

This can be used in rename or copy file

Cheers

I am trying but it is not working
It is not giving the desired output.
Also the file name I have provided is just an Example

@Kunal_Jain

Var1 is the place where you have to provide your filename(old filenmae)

Cheers

Can you help me with the xaml please

@Kunal_Jain

Please check

Path.Combine(Path.GetDirectoryName(FileLocationWIthPath),System.Text.RegularExpressions.Regex.Replace(Path.GetFileName(FileLocationWIthPath),"\d{2}-d{2}-d{4}",Now.ToString("MM-dd-yyyy")))

Rename.xaml (6.1 KB)

cheers

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