I am working on a project where I have to unzip a file and do operation and zip it back. I am doing this using powershell code.
→ this code unzips a file Expand-Archive -LiteralPath sourceFilePath -DestinationPath destinationFilePath
The problem I am facing is the powershell script does not accept wildcards.
Is there any other way to do this???
Hello @devbrath
To use the wildcard you could use vb.net within UiPath possibly, then pass the filename to the script.
I believe System.IO.Directory.GetFiles() allows a searchpattern
@balupad14
I have installed the BalaReva external activities.
My process requires me to unzip files, and some zip files have nested zips.
I have a while loop that looks to see if there are any more zips within a folder, and if so unzips.
I am getting the following error:
{
“message”: “An error has occured while unzipping the packages, error message: System.NotSupportedException: Unknown header: 892548665\r\n at BalaReva.Externals.UnZipFile.Execute(CodeActivityContext context)\r\n at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)\r\n at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)\r\n at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation) at BalaReva.Externals.UnZipFile.Execute(CodeActivityContext context)\r\n at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)\r\n at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)\r\n at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)”,
}
You will need the filepath with the name of the file, so you will need to get the files in a folder with a pattern.
You can use this: System.IO.Directory.GetFiles(folderPath, "*.zip")
Or change “*.zip” to meet your needs as a pattern. This will give you all the files in the folder, so you will need to unzip all files using a For Each loop as was suggested.
For example,
For each file In System.IO.Directory.GetFiles(folderPath, "*.zip")
Unzip // use file for SourceFilePath