How to use original file name in OnDownload?

After click download button, normally the file downloaded by browser will have its own name. But I need to save the file to specific folder. How can I save it with this original name?

This is useless:
{
“Command”: “onDownload”,
“Target”: “FolderA/FolderB/”,
“Value”: “”,
“Description”: “”
}

How should the code be like? Thanks~

If you do not use the OnDownload command, then the original file name is preserved.

If you need to copy the file from the download folder to another folder, you can trigger a basic batch file (or Python) script with the XRUN command after the download is complete.

Or you use the hard-drive mode, then the download folder is the UI Vision root folder + “/download”.

Thanks. So there’s no other method to get the original name then. Unfortunately, the XRun need XModule, which is blocked by our IT policy. Thanks anyway.

Actually, you can get the original file name. It is in the ${!Last_Downloaded_File_Name} variable: (read only) Get the name of the downloaded file. This requires ONDOWNLOAD to be inside the macro.

You could store this value e. g. in a CSV file, and then use this info you to rename the downloaded file afterwards.

Sorry to bother again. I don’t know how to use the variable. I put it in the OnDownload Target, but it says Internal variable "!LAST_DOWNLOADED_FILE_NAME" not supported. Maybe I’m not using it correctly?

I thought before using it, I have to download first to get the name and then put it in the OnDownload and download again. But it’s not. Anyway, I’m not gonna use this method anymore. Thanks anyway~

Is there a solution for this question? Thanks…

No??? Can anybody help??? @admin

Hi, the internal variable !LAST_DOWNLOADED_FILE_NAME works with V6.2.6, but is broken since version V6.2.8. At this point I am not sure if this a regression bug in our software and/or a change in the Chrome API. We will look into this.

Is there any solution for this problem now? Thanks!

We have not looked at the issue yet, but it is on our todo list.

The issue is fixed with V8.3.6, thanks for your patience :slight_smile:

Thanks. But is it possible for you to show me how to use it? I’m not getting what I want. Thanks.

    {
      "Command": "onDownload",
      "Target": "folder\\a${!Last_Downloaded_File_Name}",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "click",
      "Target": "//*[text()='EXPORT REPORT']",
      "Value": "",
      "Description": ""
    }

You need to add onDownload | | true to your macro. This makes the macro wait for the download to complete. Only then ${!Last_Downloaded_File_Name} has a value.

This works:

{
  "Name": "vvv",
  "CreationDate": "2023-5-15",
  "Commands": [
    {
      "Command": "open",
      "Target": "https://www.virtualbox.org/wiki/Downloads",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "onDownload",
      "Target": "",
      "Value": "true",
      "Description": "true = WAIT for download to complete"
    },
    {
      "Command": "click",
      "Target": "linkText=macOS / Intel hosts",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "echo",
      "Target": "File name is ${!Last_Downloaded_File_Name}",
      "Value": "pink",
      "Description": ""
    }
  ]
}

${!LAST_DOWNLOADED_FILE_NAME} is fixed with V8.3.8