To Extract ZIP file content using python/ batch file in Kryon

  • 22 January 2020
  • 0 replies
  • 14 views

You can extract zip file content using:

 

1- Python

 

>> use Run script

>> select python as language

>> enter the below code :

 

Python COde:

from zipfile import ZipFile

# Create a ZipFile Object and load sample.zip in it

with ZipFile('C:\temp\backup\myexcel.zip', 'r') as zipObj:

# Extract all the contents of zip file in different directory

zipObj.extractall('C:\temp\')

 

And then Run the wizard.

 

2- Batch File

>> Create a batch file

>> enter following code:

 

@echo off

setlocal

cd /d %~dp0

Call :UnZipFile "C: emp"" "C: empackupmyexcel.zip"

exit /b

 

:UnZipFile

set vbs="%temp%_.vbs"

if exist %vbs% del /f /q %vbs%

>%vbs% echo Set fso = CreateObject("Scripting.FileSystemObject")

>>%vbs% echo If NOT fso.FolderExists(%1) Then

>>%vbs% echo fso.CreateFolder(%1)

>>%vbs% echo End If

>>%vbs% echo set objShell = CreateObject("Shell.Application")

>>%vbs% echo set FilesInZip=objShell.NameSpace(%2).items

>>%vbs% echo objShell.NameSpace(%1).CopyHere(FilesInZip)

>>%vbs% echo Set fso = Nothing

>>%vbs% echo Set objShell = Nothing

cscript //nologo %vbs%

if exist %vbs% del /f /q %vbs%

 

 

>> Create a wizard

>> Use Run command and the browse to Batch file

 

u can also use above source and destination location as variable to make ur code dynamic.

 

Thanks.

 

Please comment if u need more assistance then i will post the video as well.

 

Regards,

ZAK


0 replies

Be the first to reply!

Reply