How to extract a specific folder from a zip file

Tags:
Powershell
Hi, I have a zip file contains folders, sub folders and files. I want to extract a specific sub folder along with files and folders in it. Can anyone suggest a way to accomplish this. I tried the below code but no luck. $xtrctfolder = "ValueaddDataCurrentadminproduction" $destination = "D:DineshFinal_xtract" Add-Type -Assembly System.IO.Compression.FileSystem $zip = [IO.Compression.ZipFile]::OpenRead($sourcePath) $zip.Entries | where {$_.Name -eq $xtrctfolder} | foreach { $target_path = [System.IO.Path]::Combine($destination, $_.Name) $target_folder = [System.IO.Path]::GetDirectoryName($target_path) if(!(Test-Path $target_folder )) { New-Item -ItemType Directory -Path $target_folder | Out-Null } if(!$target_path.EndsWith("")) { [System.IO.Compression.ZipFileExtensions]::ExtractToFile($_, $target_path, $true); } } Thanks Dinesh
0

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • Subhendu Sen
    What type of system is there? What OS is there? What tool/ software/ command are you using to do this job? How did you get this zip file? Either by an attachment or from another source?
    138,820 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: