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.