How to get the file when the folder name changes on the shared folder

“S:\Accounting\Finance\RealState\LeaseExpirationRports\CY24\Q1\RealState Leases\Real Estate_Lease Expiration_Q1 as of 03.19.24.xls”

I have this path in the shared folder

where

  1. “S:\Accounting\Finance\RealState\LeaseExpirationRports” is static and it will not change

  2. CY24 will change in next year to CY25 manually by the user

  3. Q1 can change to Q2,Q3,Q4 in CY24 and CY25 and so on.

  4. RealState Leases this part of the path will remain same.

  5. Latest file name I can get by order of descending of creation time.

  6. File name also I can get from new filinfo(Path).name

Please help me to achive this so the bot can get the file path if any folder name changes

Can you try this way once

“S:\Accounting\Finance\RealState\LeaseExpirationRports\CY2*\Q*\RealState Leases”

Hi @ahmed4566

Try this:

"S:\Accounting\Finance\RealState\LeaseExpirationRports\CY*\Q*\RealState Leases\Real Estate_Lease Expiration_Q1 as of 03.19.24.xls"

Regards

@ahmed4566 ,

You will have to calculate the Quarter and Year for this dynamic file path and then prepare final file path.

Here is sample solution you can follow:

Code:
Workflow.xaml (7.5 KB)

Thanks,
Ashok :slight_smile:

Thanks Ashok, I tried your flow
works fine , tbut the thing is the user is updating the file manaully on that path …so need to check the validation if the folder exist and file exist
then read the file by the bot

You can easily do that by this snippet.

Assign: folderExists = Directory.Exists(folderPath)
Assign: fileExists = File.Exists(filePath)

Thanks,
Ashok :slight_smile:


Hi Ashok, I am trying to take the path from the shared folder and its in argument and I have placed argument there instaed of hard coded value and then I am trying to get the latest file from that folder

No need to pass strQtr twice as you are requiring only once.

Also check the the directory path value once assign activity executes.

Thanks bro, It was my mistake as I was typing the path incorrectly…

1 Like

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