psunzipdelete

Title: UnZip  Log files and delete original zip file.
Description: If you have multibul zip files and need to unzip and delete zip file.

Note: if you want to Unzip child folders, run same script again from same location.

  • $path = “E:\Lakku”  # Zip File Location  
  • $shell_app= New-Object -com shell.application  
  • $files = Get-ChildItem -Path $path -filter *.zip -recurse  
  •   
  • foreach($file in $files)   
  • {  
  •   
  •   $zip_file = $shell_app.namespace($file.FullName)  
  •   $test= $file.Name;  
  •   $test1=$test.split(‘.zip’)[0]  
  •   $DEST=$file.DirectoryName   
  •   $test2=$DEST+"\"+$test1  
  •   New-Item -Path $test2 -ItemType 'Directory'  
  •   $copyHere = $shell_app.namespace($test2)  
  •   $copyHere.Copyhere($zip_file.items())  
  •  # Remove  
  •   Remove-Item $file.fullname -Force -filter *.zip  
  •   write-host $file.fullname  
  •   
  • }