Move a document with a certain ending

Currently I have a dynamic variable InvoiceID that contains the id of an invoice and I have the invoices in pdf that their names are for example:
9091 UDA 877987.pdf where the last 6 digits are the InvoiceID.

How can I move this document to another folder only when its ending is the ID that I have in my variable?

@JavXult - Please try like below…

image

So in your case it might be, replace the file name with something like this…path.GetFileName(yourpath).contains(InvoiceVariable)

I’m trying to put it in a “Move File” activity but because .Contains returns a Boolean value I get an error.

@JavXult - it should be like this…

If path.GetFileName(yourpath).contains(InvoiceVariable)
Then Move File
Else Do nothing

Please share the error screenshot…

That must be in a loop for it isnt?, or what properties would the “Move File” activity contain if not?.

@JavXult - is this what you are looking for?

Replace Str with your variable name…

You can also do with single line of code…

Directory.GetFiles("yourFolderName").Where(function(x) new fileinfo(x).Name.contains("InvoiceVariable"))

Then place your Move File…As shown below…

Here i am moving the pdf contains “739” to different folder…

Hope this helps…

1 Like

It works!, Thank you!

1 Like

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