Download Multiple files in a particular folder

Hi @lakshya_garg1,

A while back I wrote a PowerShell command, which can download zip files from the forum and unzips them to a target folder. You can modify it to suit your usecase i.e., only use the download file part of the script.

This tutorial will show you how to integrate a PowerShell script in UiPath and pass variables to the script. In your case, it might be multiple endpoints (URLs) of your files.

function DownloadSampleFromUiPathForum{
    # This function downloads, unzips files from the UiPath forum given the url of the file.
    param (
        [string]$SourceUrl
    )
# Lets download a sample project file and unzip 
$WebRequest = iwr $SourceUrl   # Invoke-WebRequest to get headers 
$WebRequest.Headers."Content-Disposition" -match -join("\w+.",$SourceUrl.Split(".")[-1])
$FileName = $Matches.0   # This gets us the filename from UiPath forum
$ZipFile = -join("C:\Users\", $env:UserName, "\Downloads\", $FileName)
$ExistsZipFile = Test-Path -Path $ZipFile   
# Lets download only if the file is not found
if($ExistsZipFile -eq $false){
Invoke-WebRequest -Uri $SourceUrl -OutFile $ZipFile 
Expand-Archive $ZipFile
}# if ends
}# function ends

# Calling the download function on the sample file
DownloadSampleFromUiPathForum  'https://forum.uipath.com/uploads/short-url/4j6bRIkvsRdRnsr7BhfcSHIwieF.zip'
1 Like