go2tom42

Untitled

Jun 14th, 2021 (edited)
461
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Param(
  2.     [Parameter(Position=0,mandatory=$true)]
  3.     [alias("f")]
  4.     [String]$File
  5. )
  6.  
  7. $File = Get-ChildItem $File
  8.  
  9. $Fileinfo = 7z l "$($File.FullName)"
  10.  
  11. $Total = [int]((($Fileinfo | Select-String -Pattern ' files').ToString()).Substring("53").replace('files', ''))
  12.  
  13. if ($total -gt 1) {
  14.     $command = '7z x "' + $($File.FullName) + '" -o"' + $($File.DirectoryName) + '\' + $($File.basename)+ '"'
  15.     Invoke-Expression $command
  16.     Remove-Item ("$($File.FullName)")
  17.     Remove-Item ("$($File.DirectoryName)\$($File.basename)*.$($File.Extension)")
  18.    
  19. } else {
  20.     $command = '7z x "' + $($File.FullName) + '" -o"' + $($File.DirectoryName) + '"'
  21.     Invoke-Expression $command
  22.     Remove-Item ("$($File.FullName)")
  23.     Remove-Item ("$($File.DirectoryName)\$($File.basename)*.$($File.Extension)")
  24. }
RAW Paste Data