Extracting multiple zipped files

Good day

I have a folder receiving hourly zipped files daily. I move the items in this folder daily using a get folder contents creating a list. i need to unzip them all at the end of the day. Highlighting them all does not work. how would i structure a “for each item” to extract each file into a known folder.

Hello, I believe you are using RPA drag and drop action method. We can create bat file using Custom Action script. Open the bat file to unzip

@CustomScriptAction(
    input = [src_zip,dest,script_fl]
)
def customeScript() {

    String tmp_path = "C:\\temp"
    
    try{
    		Resource.createFileFail(script_fl)
		}catch(Exception e){
		
		}
				
   String cmd = 'powershell.exe -NoP -NonI -Command Expand-Archive "' +  src_zip + '" "' + dest +'"'
	Resource.overwrite(script_fl.toString(), cmd, "UTF-8")
				
//out=ab+1
}

2 Likes

Thank you Khashim. I am using Powershell. i found a script online. i just changed the input and output folders and then created a workfusion step to read the script

Can you share the script with us?

Thank You

[2:04 PM] Robotics Eswatini
$filelocation = dir source location*.zip
foreach ($file in $filelocation) {​​​​​​​
$filename = $file.name.ToString()
$shell_app=new-object -com shell.application
$zip_file = $shell_app.namespace(“source location$filename”)
$destination = $shell_app.namespace(“destination location\EXTRACT”)
#unzip the files
$destination.Copyhere($zip_file.items())
}​​​​​​​

on work fusion 1. enter keystrokes (Win+r) 2. enter keystrokes ( powershell script loctaion) 3. enter keystrokes ({Enter})

This is the code i put in the script action:
@CustomScriptAction(
input = [‘dirsourcelocation’, ‘destinationlocation’],
)

def customScript() {

def filelocation = dirsourcelocation
foreach(file in filelocation)
{
filename=file.name.ToString()
shell-app=new-object -com shell.application
zip_file=shell_app.namespace("dirsourcelocation$filename")
destination=shell_app.namespace("destinationlocation\extract")
destination.Copyhere(zip_file.items())

}

I gave two input variables: dirsourcelocation and desintationlocation with the values. Was this done correctly? Please let me know. I am very new to workfusion and have no idea about groovy!

Hi Mvemula

I am afraid i am also new to custom scripts. that is why i ended up using the PowerShell script. I literally downloaded the script and saved it with only an amendment to the source directory and destination directory. I cannot help you with the custom script at this time.

The proof is in the pudding. Are you getting the desired results?

Check the solution here. The script provided works well with no issues! You have to create a bot task and execute it.