![]() |
| |||||||
Automation Anywhere Post messages and questions related to Automation Software here. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| |||
| I want to download some files from a web page. But, the number of folders and there names vary. Also, the number of files in each folder varies. How do I dynamically determine the number and names of the folders and the files within them to download. The files and folders show up as "controls" and I can record the actions easily. I just want to dynamically vary the controls and file names. Thanks! Phil |
| |||
| Hello, You can use ‘Loop For Each file in a folder’ and ‘Loop For Each folder in a folder’ command in two separate task. Let us say task1 contain ‘Loop For Each folder in a folder’ command and task2 contain ‘Loop For Each file in a folder’ command. If you want to perform some actions for all files in a folder, use ‘Loop For Each file in a folder’ command. Often number of files in a folder can change. You can specify a folder and this loop will run for as many times as there are number of files in that folder. You can get the name of the file by using the System Variable $FileName$. Similarly to get the extension of the file you can use $Extension$ System variable and to get the path of the folder under which this file resides use the System Variable $CurrentDirectory$. All these system variables will return empty value when used out side this looping command. Loop For Each folder in a folder command is similar to Loop for each file in a folder, except it loops for folders, not files. To access the folder name within the loop use the System Variable, $FolderName$. Now, you can run task2 from task1, within Loop For Each folder in a folder command, using ‘Run Task’ command. Assign value of variable "$FolderName$" to Clipboard so that we can use it in task2 for downloading each file in current folder. The text format of task1 will look something like this: 1) Start Loop " Each Folder in http:\www... \FolderName " //Give Folder Path 2) Assign value of variable "$FolderName$"to Clipboard 3) Run Task "C:\Documents and Settings\ My Documents\Automation Anywhere\Automation Anywhere\My Tasks\ task2.atmn" 4) End Loop The text format of task2 will look something like this: 1) Start Loop " Each File in http:\www... \FolderName\$Clipboard$" 2) Download file 'C: \ DownloadFolder\$FileName$' from 'http://www….' 3) End Loop Hope that helps. |
| |||
| The code you supplied seems to imply a folder that I can access via drive letter or URL. I cannot do that with these files and folders. I don't have access to the "folder" on the remote web server. I can only access these as dynamically built ASP pages that list the files and folders as controls. |
| |||
| Here is what one row of the web page looks like. It is dynamically built depending on the number of files in the folder. How can I dynamically build code to download an arbitrary number of these files? https://counties.gov/CPQ/download.as...5Freview%2ECSV |