Hi everyone,
I have a folder containing bunch of files with naming (Report_BuName.xlsx). I am looping through each file in a folder to preform some actions where I require the BuName of each file.
Thanks in advance!
Hi everyone,
I have a folder containing bunch of files with naming (Report_BuName.xlsx). I am looping through each file in a folder to preform some actions where I require the BuName of each file.
Thanks in advance!
Try this
System.Text.RegularExpressions.Regex.Match(Input.ToString,"(?<=Report_)(\w+)").Value
Cheers!!
You’re using for each file in folder so take input as Currentfile.Name
Or
Directly you can give this
Currentfile.Name.Split(“_”)(1).Split(“.”)(0)
Input="Report_BuName.xlsx"
Input.Split("_")(1).Split(".")(0)
Hope this helps!!
Hi,
FYI, another approach:
System.Text.RegularExpressions.Regex.Match(System.IO.Path.GetFileNameWithoutExtension(CurrentFile.Name),"[^_]+$").Value
Regards,
Inside the for each file in folder use the following
CurrentFile.Name.Split({"_","."},3,StringSplitOptions.None)(1)
Hope this helps
Cheers
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.