If filename contains xxx then upload file

Hi all,

I’m trying to code the following:

I have a folder in which files are saved with the following filename: projectnumber_versionY.xlsx
Per project number, minimum 1 version is saved and maximum 3 versions. If version3 exists then i need to upload version 3 of that projectnumber, else version 2, else version 1. The uploading is not a problem, I am stuck at building the logic to assess which version to upload.

Thanks

Hi @yannip,

Using Path.getfile property get all the files from the folder.

Using Path.exists check ur 3 version if it’s available then upload that file else check the next version .

Regards,
Arivu

1 Like

Hi @arivu96

Thanks for your reply.
Could you give an example? Also, i’m still wondering how to determine that it should be done for each project number in that folder.

Thanks!

okay, you can try this.
Once you get all the files from the folder you will have a list of files
Now loop through each file (for-each) and extract the ‘projectnumber’ by using substring before _
Create a var initialize to 3 and then create a while (we are inside the first for-each) var = 1
now check if path.exists using the concat(“projectnumber_”, “var”, “.xlsx”)
if exist upload or it will loop through the rest and find the lower version

Like this for each projectnumber from 3 to 1 you will search and upload.

Hope it helps.:robot:

1 Like

@yannip

here is the solution you required it was developed using 2018.3 i don’t know which version you might be using I am attaching step by step code in excel. let me know if you need any more clarification.
Main.xaml (10.9 KB)
Main.xlsx (3.3 KB)

regards,
Pathrudu Chintakayala

@pathrudu, thanks for the sample code.

Could you please clarify the following two lines of code:
Line 21 in the excel (what is the (" \ ") and the -1 or +1 doing?)
Line 39 in the excel

Thanks!

@yannip

string manipulation to extract the file name from complete path so after (" \ ") will be the file name/projectNumber.

regards,
Pathrudu

1 Like

Thank you for getting me in the right direction @pathrudu, @nadim.warsi, @arivu96.
I’m not completely there yet, but by combining your input I think I’ll get there.