Differences

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

2017-01-15 2017-02-02
options explicit anchor (martin) when local direcory was initially empty, detection of deleted local files failed (t=24471) (martin)
Line 20: Line 20:
# @command      powershell.exe -ExecutionPolicy Bypass -File "%EXTENSION_PATH%" -sessionUrl "!S" -localPath "%LocalPath%" -remotePath "%RemotePath%" %Delete% %Beep% %ContinueOnError% -interval "%Interval%" -pause -sessionLogPath "%SessionLogPath%" # @command      powershell.exe -ExecutionPolicy Bypass -File "%EXTENSION_PATH%" -sessionUrl "!S" -localPath "%LocalPath%" -remotePath "%RemotePath%" %Delete% %Beep% %ContinueOnError% -interval "%Interval%" -pause -sessionLogPath "%SessionLogPath%"
# @description  Periodically scans for changes in a remote directory and reflects them on a local directory # @description  Periodically scans for changes in a remote directory and reflects them on a local directory
-# @version      2+# @version      3
# @homepage    ~~SELF~~ # @homepage    ~~SELF~~
# @require      WinSCP 5.9.2 # @require      WinSCP 5.9.2
Line 111: Line 111:
                # scan for removed local files (the $result does not include them)                 # scan for removed local files (the $result does not include them)
                $localFiles2 = Get-ChildItem -Recurse -Path $localPath                 $localFiles2 = Get-ChildItem -Recurse -Path $localPath
-                $changes = Compare-Object -DifferenceObject $localFiles2 -ReferenceObject $localFiles 
-                 
-                $removedFiles = 
-                    $changes | 
-                    Where-Object -FilterScript { $_.SideIndicator -eq "<=" } | 
-                    Select-Object -ExpandProperty InputObject 
-                # Print removed local files +                if ($localFiles)
-                foreach ($removedFile in $removedFiles)+
                {                 {
-                    Write-Host ("{0} deleted" -f $removedFile) +                    $changes = Compare-Object -DifferenceObject $localFiles2 -ReferenceObject $localFiles 
- ···················$changed = $True+                 
 +                    $removedFiles = 
 +                        $changes | 
 +                        Where-Object -FilterScript { $_.SideIndicator -eq "<=" } | 
 +                        Select-Object -ExpandProperty InputObject 
 + 
 +                    # Print removed local files 
 +                    foreach ($removedFile in $removedFiles) 
 +                    { 
 +························Write-Host ("{0} deleted" -f $removedFile) 
 + ·······················$changed = $True 
 +                    }
                }                 }

Last modified: by martin