Differences

This shows you the differences between the selected revisions of the page.

2016-05-25 2016-05-25
logging (martin) configurable (martin)
Line 17: Line 17:
<code powershell - ZipUpload.ps1> <code powershell - ZipUpload.ps1>
# @name        &ZIP and Upload... # @name        &ZIP and Upload...
-# @command      powershell.exe -ExecutionPolicy Bypass -File "%EXTENSION_PATH%" -sessionUrl "!S" -remotePath "!/" -archiveName "!?&Archive name:?archive.zip!" -pause -sessionLogPath "%SessionLogPath%" !&+# @command      powershell.exe -ExecutionPolicy Bypass -File "%EXTENSION_PATH%" -sessionUrl "!S" -remotePath "!/" -archiveName "!?&Archive name:?archive!" -pause -sessionLogPath "%SessionLogPath%" %Use7zip% -path7zip "%Path7zip%" -archive7zip %Archive7zip% !&
# @description  Packs the selected files to a ZIP archive and uploads it # @description  Packs the selected files to a ZIP archive and uploads it
# @flag        ApplyToDirectories # @flag        ApplyToDirectories
Line 24: Line 24:
# @homepage    ~~SELF~~ # @homepage    ~~SELF~~
# @require      WinSCP 5.8.3 # @require      WinSCP 5.8.3
 +# @option      Use7zip checkbox "Use &7-zip" "" -use7zip
 +# @option      Path7zip file "7-zip &path (7z.exe/7za.exe):" "C:\Program Files\7-Zip\7z.exe"
 +# @option      Archive7zip dropdownlist "&Archive type (with 7-zip):" zip zip 7z xz gzip bzip2 tar
# @option      SessionLogPath file "&Session log file:" # @option      SessionLogPath file "&Session log file:"
 +# @optionpoge  ~~SELF~~#options
param ( param (
Line 35: Line 39:
    [Switch]     [Switch]
    $use7Zip = $False,     $use7Zip = $False,
 +    # The 7z.exe can be replaced with portable 7za.exe
 +    $path7zip = "C:\Program Files\7-Zip\7z.exe",
 +    $archive7zip = "zip",
    [Parameter(Mandatory)]     [Parameter(Mandatory)]
    $archiveName,     $archiveName,
Line 44: Line 51:
try try
{ {
-    Write-Host (&quot;Archiving {0} files to archive {1}..." -f $localPaths.Count, $archiveName)+    if ($use7Zip) 
 + ···{ 
 +········$archiveName += &quot;." + $archive7zip 
 +····} 
 +   else 
 +    { 
 +········$archiveName += ".zip" 
 +    }
 +    Write-Host ("Archiving {0} files to archive {1}..." -f $localPaths.Count, $archiveName)
 +   
    $archivePath = Join-Path ([System.IO.Path]::GetTempPath()) $archiveName     $archivePath = Join-Path ([System.IO.Path]::GetTempPath()) $archiveName
Line 57: Line 73:
    {     {
        # Create archive         # Create archive
-        # The 7z.exe can be replaced with portable 7za.exe +        & "$path7zip&quot; a &quot;-t$archive7zip" $archivePath $localPaths
-········& "C:\Program Files\7-Zip\7z.exe" a -tzip $archivePath $localPaths+
        if ($LASTEXITCODE -gt 0)         if ($LASTEXITCODE -gt 0)
Line 145: Line 160:
exit $result exit $result
</code> </code>
 +
 +===== Options =====
 +When the //Use 7-zip// is not checked, the extension uses a native .NET framework implementation for a ZIP compression. In this mode, the extension has no additional dependency. Particularly, if you want to use a different archive type, check the //Use 7-zip// and install the [[http://www.7-zip.org/download.html|7-Zip]].
 +
 +Use the //7-zip path// to select an alternative path to the ''7z.exe'' or ''7za.exe'', particularly if you are using a portable version.
 +
 +When using 7-Zip, you can use the //Archive type// to select the archive type to create.
 +
 +In the //Session log file// you can specify a path to a [[logging|session log file]] (for uploading).
 +

Last modified: by martin