cancel
Showing results for 
Search instead for 
Did you mean: 

Using Move Files function in File Management Utility - But my file names are dynamic

HirenMota
Staff
Staff
Hello Everyone,

I am new to Blue prism and am trying to build a logic for extracting reports from a custodian portal and saving it on a common path which can be accessed by others.

I have built majority of the logic but stuck at below two points:

1. Files downloaded on Chrome browser - I need to move these files from the downloads folder to a specific folder. "Move Files" function works when i give the exact file name. But file name is dynamic meaning it basically has the COB date at the end of the file name which will be different each day the report downloads.

Unfortunately Wildcard option doesn't apply here. Could someone guide me to have a logic in place which identifies the file from the beginning few characters and moves it a common path.

2. I need to extract reports for Close of business dates. But on Monday the file runs for previous day which is Sunday. Could someone guide me on the logic or formulae for the program to run only on weekdays and on Monday it automatically runs for COB Friday.

Current Formulae: FormatDate(AddDays(Today(),-1), "dd/MM/yyyy")

Thanks and Regards

Hiren Mota

------------------------------
Hiren Mota
------------------------------
4 REPLIES 4

I have done something similar in the past and used the following logic; ignore the syntax, just trying to share the logic:

Get Current Date
Set Data Item [FileDate] to [CurrentDate]
Loop
    Set [FileDate] to [FileDate - 1 day]
    If File Exists [Filename]_[FileDate]
        Move File
        Exit Loop
    End (If/Decision)
End(Loop)

So, if the file doesn't exist (today - 1), this will loop back through going back one day at a time until it finds the file.

Good luck!

------------------------------
Michael Annis
------------------------------

diane.sanzone
Level 7
Hi Hiren,

First, welcome to Blue Prism!  Second, you've got a lot going on in this post. I'll try to answer as best I can.

1. Files downloaded on Chrome browser - I'm not quite sure where you're stuck so I'll point out a few BP things that might be helpful. If you still need more please reply and we'll dig deeper.
--There is a "Left()" and "Right()" function under "Text" in the expression editor of calculation stages.  If you've already got the file name and know what the first few characters are, you could try something like Lower(Left([FileName],4))="file" (or whatever the first 4 characters of your file name are).  If the syntax is difficult, don't stress it - just use the editor capabilities until you get comfortable with it. That comes with time and experience.
--If you know your folder (which it seems you do), you can also try using the "Get Files" action in the File Management Utility (Blue Prism canned object). That will get you all the files in a particular folder that match the criteria you set.  If you know the first few characters and the extension, you can put "file*.*" in the "Patterns.csv" input to that action (see below).  This action will give you output of a collection of all the files in that folder that match your criteria.

611.png
2. As for running the schedule for weekdays and only of last business day, this is one you'll probably write now and then modify 100 times in your career until you find something you love, but you actually have 2 questions here:
-Q-How do I get the bot to only run on weekdays? A-This isn't something you set in the code. The control room operator will schedule the bot to only run on weekdays from the schedule using the calendars in Blue Prism. If you don't have a "weekdays only" calendar, you might have to build one to add to your package, but this isn't something you do with code typically.
Q-How do I get my bot to process files as of the last business day when it runs on Mondays? A- You could try something like
--FormatDate(Today(), "ddd") - this will get you the day of the week in letters (so Mon, Tue, etc.) THEN
--In a decision stage, use the result of that calculation to see if it's Monday like this ([DayofWeek0="Mon") - if yes, then take today's date, subtract three, and use that as your file dates. If not, then just proceed. 

You can also put both calculations in the decision stage, if you're comfortable with it. Like this
(FormatDate(Today(), "ddd"))="Mon" (your "yes" path is for today is Monday, your "no" path is for every other day of the week)
This can get a little tricky if you need to work around holidays and such, so keep that in mind also as you develop.  If that is a concern, you'll want to stick with Michael's logic or something similar to make sure you don't miss any dates.

I hope all this helps, and good luck!

------------------------------
Diane Sanzone
------------------------------

Hi Diane / Michael,

Thank you for your responses.

I would like to update on the status; I have been able to resolve the issue related to Weekend runs, by using IsWeekend function.

On the other query, i have attached a word document; could you please review and advise what i can do to fix it.

Thank & Regards

Hiren Mota

------------------------------
Hiren Mota
------------------------------

Hi Hiren,

You can also pass multiple extensions to filter out both of your file types.

613.png
Also in google chrome we can change the default download directory if Download folder is causing file mixing.

------------------------------
If I was of assistance, please vote for it to be the "Best Answer".

Thanks & Regards,
Tejaskumar Darji
Sr. Consultant-Technical Lead
------------------------------