Read Name File With Condition

I have file name :
7. ABCD EFG 170223. txt

  • under the condition
    7. is static name
    ABCD EFG 170223 is dynamic name

what if I want to read the filename “7.” only?

HI,

Do you mean you want to read files which name starts with “7.”?

If so, the following will work.

files = System.IO.Directory.GetFiles(System.Environment.CurrentDirectory,"7.*.*")

Regards,

Hi @samarasenja

How about this following:

1.Use the “Assign” activity to create a new string variable called fileName.
2.Assign the file path to the fileName variable.
3.Use the Path.GetFileNameWithoutExtension method to get the file name without the extension.
4.Pass the fileName variable as an argument to this method.
5.Use Assign activity IsMatchVal as a variable.

Assign fileName = "C:\Users\user\Documents\7. ABCD EFG 170223.txt"
Assign fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileName)
If activity IsMatchVal = System.Text.RegularExpressions.Regex.IsMatch(fileNameWithoutExtension ,"^7")

image

Regards
Gokul

What is Variable Types Files?

HI,

Can you try String array?

image

eror on this

how about ABCD EFG 170223 Is dynamic Name?

Hi,

Can you try to set String at TypeArgument in ForEach activity?

Regards,

HI,

Also it’s necessary to set your target folder instead of System.Environment.CurrentDirectory, as the following.

System.IO.Directory("d:\DATA NOSTRO\PROCESSING DATA\17-19\Data","7.*.*")

Regards,

Not yet, sorry can you describe flow?

HI,

Can you try the following sample?

Sample20230405-6L.zip (3.2 KB)

Regards,

Hi, this is solved…
Thank you so much

1 Like

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