Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: "Remote Sync" Get list of files removed from FTP site

There's no event for that.

But you can get list of all removals (as well as all uploads=updates) from SynchronizationResult returned by Session.SynchronizeDirectories:
https://winscp.net/eng/docs/library_synchronizationresult
kenny782

"Remote Sync" Get list of files removed from FTP site

So I have done alot of searching without luck.

I'm doing a one way sync Local to Remote(FTP) via Powershell
It's working great and I worked in some reporting and email.

Problem
One thing I can't figure out how to do....
I want to capture a list of any files that are removed on the FTP site (because they no longer exist locally).

However I can't find an event or example to do that.
I found an example using Get-ChildItem -Recurse But that was designed to capture the local directory before and after.
I need to either list the FTP site before and after to compare or discover an event I haven't found that will let me append to my log file what was removed.

Seems like a worthy Feature Request for SynchronizeDirectories :D


And this isn't a must but if anyone has any ideas on how I can tell the difference between a new file uploaded vs an existing file I just updated from local that would be nice

function FileTransferred

{
   param ($e)
   
   if ($e.Error -eq $Null)
   {
      Write-Host ("Upload of {0} succeeded" -f $e.FileName)
      Add-Content -Path $LogFile -Value ( "`nUpload of file succeeded"+"   "+$e.FileName )
   }
   else
   {
      Write-Host ("Upload of {0} failed: {1}" -f $e.FileName, $e.Error)
      Add-Content -Path $LogFile -Value ( "`nUpload of file failed: "+"   "+$e.FileName+"    Error: "+$e.Error )
   }
   
<#   if ($e.Chmod -ne $Null)
   {
      if ($e.Chmod.Error -eq $Null)
      {
         Write-Host ("Permisions of {0} set to {1}" -f $e.Chmod.FileName, $e.Chmod.FilePermissions)
      }
      else
      {
         Write-Host ("Setting permissions of {0} failed: {1}" -f $e.Chmod.FileName, $e.Chmod.Error)
      }
      
   }
   else
   {
      Write-Host ("Permissions of {0} kept with their defaults" -f $e.Destination)
   }
   
   if ($e.Touch -ne $Null)
   {
      if ($e.Touch.Error -eq $Null)
      {
         Write-Host ("Timestamp of {0} set to {1}" -f $e.Touch.FileName, $e.Touch.LastWriteTime)
      }
      else
      {
         Write-Host ("Setting timestamp of {0} failed: {1}" -f $e.Touch.FileName, $e.Touch.Error)
      }
      
   }
   else
   {
      # This should never happen during "local to remote" synchronization
      Write-Host ("Timestamp of {0} kept with its default (current time)" -f $e.Destination)
   }#>
}



Thanks,

Kenny :)