Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

How can I determine if zip files are done being written to?

$
0
0

Hi,

I have a powershell script that downloads a bunch of data and zips the directories up. It is really great that the zipping of several directories happen in parallel but I find that my script continues to run to the end which is currently fine. I need a way to determine when the zip file is no longer in use (no longer having files added) and then do some other processing that is dependent that the files exist and are completed as I need the file has and the file size among other things.

Any ideas to know when all the zipping has completed?

 

By the way this is the zipping part of the script:

 

function out-zip
{
  Param([string]$path)

  if (-not $path.EndsWith('.zip')) {$path += '.zip'}
 
  if (-not (test-path $path)) {
    set-content $path ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18))
  }
  $ZipFile = (new-object -com shell.application).NameSpace($path)
  $input | foreach {$zipfile.CopyHere($_.fullname)}
}

foreach ($file in $fileObjects)
{
    if($file.IsSymbols -eq '$true')
    {
        Get-Item ($file.SymbolsLocalPath) | out-zip $file.SymbolsLocalPath
    }
}

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles