Downloading file and renaming it

Hi All,

I have 2 questions:

I am downloading the file with the help of API and it downloads in location (E: drive, however I managed to get the folder paths of the downloaded file).

Also, the file which is getting downloaded is showing different name when I am reading it with BOT. (Occurring every time when I run the BOT)

Q1. Can any one please help me to extract the exact filename just after downloading? Here is the screenshot of the file which got downloaded in the E: drive.

Q2. How can I fetch the particular folder path (I am using Get Folder Info activity), where my file is getting downloaded by skipping the filename?
(For eg:
Path = “E:\packages\xyz\1.0\content\attachment_064076fc-ec6-5c9465bcc9c8.tiff”
And I want → Path = "E:\packages\xyz\1.0\content")

Tried:
→ Tried renaming & moving the filename just after downloading but I am not able to read the exact filename which got downloaded.

My aim is to to rename the file once it has been downloaded and move it to some specific folder.

How we can achieve this?

BR,
NK

@Nitesh

  1. Ideally api would give the filename in response or you would use response attachment field in pai to save the file…is it not the case?
  2. If you know the folder where it is downloaded then why do you want to extract the folder from the string again?
  3. If you know folder where downloaded then can do a directory.getfiles on the folder and get latest file

Cheers

@Anil_G

Thank you for your response.

  1. Yes, you are right. It is giving the name of the file as I posted in above screenshot but the problem is - File which is getting downloaded is not same name as api provides. (Check & match the attached filename in the above screenshot)

  2. So my next plan is if I can get rid of just the filename (eg in this case - "attachment_064076fc-ec6-5c9465bcc9c8.tiff”), then I can iterate it in that folder ( “E:\packages\xyz\1.0\content") and try to rename the file with the correct name.

Just FYI - In my local machine, folder the file is getting downloaded in my local machine is “C:/” and in VDI it is “E:/” drive as I shared in the above screenshot.

  1. I can try this after Step 2 above.

BR,
NK

Hi @Nitesh

How about keeping the HTTP Request activity inside the Wait For Download activity

The downloadedFile variable created will give you the information about the filename and directories

Note: Monitored Folder should be the folder in which the file will be downloaded. The downloadedFile variable is of type System.IO.FileInfo

2 Likes

Hi @kumar.varun2 ,

Thank you for providing the solution.

After implementing “Wait for Download” activity, I am able to get the exact same filename as it is downloaded, but the problem now is when I start running my process, the file is immediately getting downloaded even before running the step of my main process where I am using HTTP request. Please check the below screenshot for more reference.

How can I get rid of this?

NOTE: I have cleaned up items from the queue before running the process.

BR,
NK

File is expected to download while calling HTTP request rite? How come it is getting downloaded before calling this activity. Correct me if my understanding is wrong. If you are referring to the temporary files which is getting downloaded before the actual download - You can utilize the field “Ignore these temporary file extensions” and provide the expected extensions there so that it will wait till the actual file is getting downloaded

Hi @sharazkm32 ,

Yes, you are right. It is getting downloaded before calling this activity.

So, do you mean I need to mention the file extensions in the field “Ignore these temporary file extensions?”

In my case, 2 files are getting downloaded “Tiff” and “Pdf”. So how we can achieve this?

BR,
NK

Little confused- How is the file getting downloaded before calling the HTTP activity. Which activity is downloading the file without including in the code?

Include Tiff in the field “Ignore these temporary file extensions" and give a try

Also there could be intermediate files generated before downloading the pdf- you can include those extensions as well in coma separated

Give a try and let me know

1 Like

Hello @sharazkm32 ,

My bad, actually while publishing package there was already pdf file available in my package folder. I removed that and republished it (No more file available now).

Thank you for your help. It is working fine now.

BR,
NK

1 Like

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