ONDOWNLOAD
(LinkToClipboard)From iMacros
iMacros automatically detects and intercepts downloads. With this command, which has to occur before the download starts, the location and name of the saved file is determined. The general web page timeout also applies to downloads. Make sure that the timeout value is long enough to cover the complete download time. Alternatively, you can add a WAIT SECONDS=#DOWNLOADCOMPLETE#, which will cause iMacros to wait with the next command until the download has finished. Normally the download file name is created automatically by the website. You can add parts to the original file name by using the + syntax (see Examples). The built-in variable !NOW is helpful in this context.
Contents |
Syntax
ONDOWNLOAD FOLDER=folder_name FILE=file_name
Parameters
- FOLDER
- Specifies the folder in which the file is saved. Use * for the standard download folder specified in the options.
- FILE
- Specifies the file name under which the file is saved. If no file extension is given, the default file extension is used. Use * for the original file name. Use +something to add something to the original file name before the file extension.
Examples
Suppose you download a file originally called setup.exe. The following snippet will save this file under the original file name in the default folder:
ONDOWNLOAD FOLDER=* FILE=*
This command will save the file in the C:\MyFiles\ folder under the name myDownload.exe:
ONDOWNLOAD FOLDER=C:\MyFiles\ FILE=myDownload.exe
And finally, this command will save the file in the default directory under the name with an added date stamp (using the !NOW variable), e.g. setup_060525.exe.
ONDOWNLOAD FOLDER=* FILE=+{{!NOW:yymmdd}}
Note: The "+" symbol is only required if you want to add text to the default file name (as created by the website). In this case, "+" must be the first symbol, directly after FILE=+... . The "+" is not required (and not allowed) if you want to concatenate several variables. To concatenate variables just use them as part of the string. Example: FILE=invoice_no{{number}}_unit{{departement}}.pdf
Example macros: Demo-FileDownload, Demo-ImageDownload
See Also
ONCERTIFICATEDIALOG, ONDIALOG, ONERRORDIALOG, ONLOGIN, ONSECURITYDIALOG, ONWEBPAGEDIALOG
