How to get File name first two words and rename it ?
EX: New File 584213665463462541
Get the file which has name “New File *” and rename it with current date.
How to get File name first two words and rename it ?
EX: New File 584213665463462541
Get the file which has name “New File *” and rename it with current date.
I already mentioned . Need to get the file which starts with "File Name " and then rename it as File name 06-06-2024.
File should be file name 1326946546, File name 0003602421…
Hi @Pal_Patel
Use For Each File in Folder and give your folder path. Inside that use If Condition and give condition like below:
If
CurrentFile.Name.StartsWith("File Name")
Then
Assign -> FileName = System.Text.RegularExpressions.Regex.Replace(CurrentFile.Name,"\d+",Now.ToString("dd-MM-yyyy"))
Rename File Activity
File: CurrentFile.ToString
New Name: FileName
End If
Check below workflow:
XAML:
Sequence47.xaml (10.6 KB)
Regards
Iterate through all the files in your folder using For Each File in Folder activity.
Inside it use assign activity to get file name and modify it with this logic.
String.Join(" ",Path.GetFileNameWithoutExtension(CurrentFile.FullName).Split(" ").Take(2))+" "+Now.ToString("dd.MM.yyyy")+Path.GetExtension(CurrentFile.FullName)
Sample Solution:
Input:
Output:

Sample Code:
Workflow.xaml (11.4 KB)
Updated solution to check file name starting with " New File "
Thanks,
Ashok ![]()
Thanks but this is not changing the file name as I execute. Also I am moving the file to new location.
Thanks but for me it is not changing name as I have file naME : FileName_12_22568567-3194-4642-a42a-ec331681cd83.xls
Hi @Pal_Patel
Please check the below attached xaml and let me know if still any changes required:
Xaml:
Sequence47.xaml (11.8 KB)
Regards
It’s as per your inputs buddy!
Hope you will be able to customize it as per your requirement. We could not help with a concreate solution as we are unaware of your code/requirement. We just try to show you possible approach to achieve the outcome. For rest, you will have to take the efforts.
Thanks,
Ashok ![]()
Hi @Pal_Patel
Buddy, Can you please confirm me your query?
Your file names are like “FileName_12_22568567-3194-4642-a42a-ec331681cd83.xls” in this format and you want to change the filename like “FileName_12_22568567-3194-4642-a42a-ec331681cd83.xls” + currentdate
Correct??