Differences

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

library_example_find_duplicate_files 2017-10-04 library_example_find_duplicate_files 2022-06-16 (current)
Line 12: Line 12:
<code batch> <code batch>
-powershell.exe -File C:\path\FindDuplicates.ps1 -remotePath "/path" -remoteChecksumAlg sha-1+powershell.exe -File C:\path\FindDuplicates.ps1 -sessionUrl "sftp://user:password;fingerprint=ssh-rsa-xxxxxxxxxxx...@example.com/" -remotePath "/path" -remoteChecksumAlg sha-1
</code> </code>
<code powershell - FindDuplicates.ps1> <code powershell - FindDuplicates.ps1>
# @name        Find &Duplicates... # @name        Find &Duplicates...
-# @command      powershell.exe -ExecutionPolicy Bypass -File "%EXTENSION_PATH%" -sessionUrl "!S" -remotePath "!/" -pause -remoteChecksumAlg "%RemoteChecksumAlg%" -sessionLogPath "%SessionLogPath%"+# @command      powershell.exe -ExecutionPolicy Bypass -File "%EXTENSION_PATH%"
 +#                  -sessionUrl "!E" -remotePath "!/" -pause
 +#                  -remoteChecksumAlg "%RemoteChecksumAlg%" -sessionLogPath "%SessionLogPath%"
# @description  Searches for duplicate files on the server, starting from the current directory # @description  Searches for duplicate files on the server, starting from the current directory
# @flag        RemoteFiles # @flag        RemoteFiles
-# @version      5 +# @version      8 
-# @homepage    https://winscp.net/eng/docs/library_example_find_duplicate_files +# @homepage    ~~SELF~~ 
-# @require      WinSCP 5.9.1 +# @require      WinSCP 5.16 
-# @option      RemoteChecksumAlg -config -run combobox "&Checksum:" "local" "local=Local sha-1" "sha1=Remote sha-1" "sha256=Remote sha-256" "md5=Remote md5" +# @option      RemoteChecksumAlg -config -run combobox "&Checksum:" "local"
 +#                  "local=Local sha-1" "sha1=Remote sha-1" "sha256=Remote sha-256"
 +#                  "md5=Remote md5"
# @option      SessionLogPath -config sessionlogfile # @option      SessionLogPath -config sessionlogfile
-# @optionspage  https://winscp.net/eng/docs/library_example_find_duplicate_files#options+# @optionspage  ~~SELF~~#options
param ( param (
-    # Use Generate URL function to obtain a value for -sessionUrl parameter. +    # Use Generate Session URL function to obtain a value for -sessionUrl parameter. 
-    $sessionUrl = "sftp://user:mypassword;fingerprint=ssh-rsa-xx-xx-xx@example.com/",+    $sessionUrl = "sftp://user:mypassword;fingerprint=ssh-rsa-xxxxxxxxxxx...@example.com/",
    [Parameter(Mandatory = $True)]     [Parameter(Mandatory = $True)]
    $remotePath,     $remotePath,
Line 61: Line 65:
            else             else
            {             {
-                Write-Host "Error downloading file ${remotePath}: $($transferResult.Failures[0])"+                Write-Host
 +····················"Error downloading file ${remotePath}: $($transferResult.Failures[0])")
                $checksum = $False                 $checksum = $False
            }             }
Line 68: Line 73:
        {         {
            Write-Host "Request checksum for file $remotePath..."             Write-Host "Request checksum for file $remotePath..."
-            $checksum+            $buf = $session.CalculateFileChecksum($remoteChecksumAlg, $remotePath) 
- ···············[System.BitConverter]::ToString($session.CalculateFileChecksum( + ···········$checksum = [System.BitConverter]::ToString($buf)
-                    $remoteChecksumAlg, $remotePath))+
            Write-Host "File $remotePath checksum is $checksum"             Write-Host "File $remotePath checksum is $checksum"
        }         }
Line 168: Line 172:
    $result = 0     $result = 0
} }
-catch [Exception]+catch
{ {
    Write-Host "Error: $($_.Exception.Message)"     Write-Host "Error: $($_.Exception.Message)"
Line 190: Line 194:
The //Checksum// selection allows you to choose, what checksum algorithm to use and if the checksum is to be calculated locally or remotely. Select the //Local sha-1// to calculate SHA-1 checksum locally. This is an universal option that will work with any server, but WinSCP will need to download all candidate files locally. If you know that the server supports [[protocols|a protocol extension for calculating checksums]], you can improve the extension efficiency by selecting a remote calculation. The list contains some common algorithms that some servers support. However you can type in name of any other algorithm supported by the server. The //Checksum// selection allows you to choose, what checksum algorithm to use and if the checksum is to be calculated locally or remotely. Select the //Local sha-1// to calculate SHA-1 checksum locally. This is an universal option that will work with any server, but WinSCP will need to download all candidate files locally. If you know that the server supports [[protocols|a protocol extension for calculating checksums]], you can improve the extension efficiency by selecting a remote calculation. The list contains some common algorithms that some servers support. However you can type in name of any other algorithm supported by the server.
-In the //Session log file// you can specify a path to a [[logging|session log file]]. The option is available on the [[ui_pref_commands|Preferences dialog]] only. +In the //Session log file//, you can specify a path to a [[logging|session log file]]. The option is available on the [[ui_pref_commands|Preferences dialog]] only. 
- + 
 +In the //Keyboard shortcut//, you can specify a [[custom_key_shortcuts|keyboard shortcut]] for the extension. The option is available on the [[ui_pref_commands|Preferences dialog]] only.

Last modified: by martin