When your destination directory already contains all the previously transferred files, synchronize source directory to destination directory, instead of simple transfer.
With WinSCP .NET assembly that means, use
Session.SynchronizeDirectories, with argument
mode set to
SynchronizationMode.Local instead of
When the old files are removed from the destination directory, you can instead select the new files based on timestamp.
put -filemask="*>=1D" *
$transferOptions = New-Object WinSCP.TransferOptions $transferOptions.FileMask = "*>=1D" $session.PutFiles("d:\toupload\*", "/home/user/", $False, $transferOptions)
If you need to select file specifically created/modified today (not simply in the last 24 hours), you need to generate a file mask with absolute timestamp constraint, like
For scripting, you need to generate the mask using your favorite scripting language.1)
For WinSCP .NET assembly, use
System.DateTime class. For example in PowerShell:
$transferOptions = New-Object WinSCP.TransferOptions $transferOptions.FileMask = ("*>=" + $(Get-Date -Format "yyyy-MM-dd")) $session.PutFiles("d:\toupload\*", "/home/user/", $False, $transferOptions)
You can also use
%TIMESTAMP% syntax to generate “today” time constraint, e.g.
Site design by Black Gate