Splitting a file path that comes in as a transaction item

Hello guys,

I have an automation where I have to create a folder with the File name of the file that I’m currently processing. My dispatcher populates a queue with the paths of the (files (written as string) that I need to process . My performer should create a folder with only the file name!!

So basically - in_TransactionItem.ToString would be : “C:\Users\yadayada\dog.zip”

And the folder that the performer needs to create would be named “dog” .

I’ve already tried the path.getfilename method but it doesn’t seem to apply to this. Should I use the Split method?

Thanks a lot as always guys…

Alex

Hi Alex,
There is also Path.GetFileNameWithoutExtension method, better in your case :slight_smile:
Kind Regards

Hello

Another option is to use Regex and an Assign activity. Preview the pattern here.

image

Assign left:
str_Result

Assign Right:
System.Text.RegularExpressions.Regex.Match(YOURSTRINGVARIABLE, “[^\]+(?=..*$)”).Tostring

You can learn Regex here:

Hopefully this helps :blush:

Cheers

Steve

Hi @alex_T split with last index and replace.zip with “” and put it into create folder activity

split(in_TransactionItem.ToString,“").lastindex.replace(”.zip",“”)

Thanks man, this worked a bunch!

Have a nice day! And thanks to everybody that brought up a solution.

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