Question about WinSCP.Session.GetFiles().Transfers
Hi.
I've been playing around with some of the scripts here in order to set up continuous one-way file replication. This works incredibly well, and I'm stoked! Well, almost ;)
Thing is, as long as I only transfer files, there's only joy. If there are folders in the mix things get a little bit more tricky.
In my example, the folder has a newer timestamp than the files contained inside it. Why that is I have no idea, but it doesn't really matter. It's like that. Now, the code snippet (yes, I've removed code for brevity (?) and it's probably important) will test for the newest *file*. It will not take folders into account. And so it will continue to download empty folders.
Is there a way to also look for the folder timestamp?
Thanks!
I've been playing around with some of the scripts here in order to set up continuous one-way file replication. This works incredibly well, and I'm stoked! Well, almost ;)
Thing is, as long as I only transfer files, there's only joy. If there are folders in the mix things get a little bit more tricky.
In my example, the folder has a newer timestamp than the files contained inside it. Why that is I have no idea, but it doesn't really matter. It's like that. Now, the code snippet (yes, I've removed code for brevity (?) and it's probably important) will test for the newest *file*. It will not take folders into account. And so it will continue to download empty folders.
Is there a way to also look for the folder timestamp?
Thanks!
$session = New-Object WinSCP.Session $transferResult = $session.GetFiles($sourcePath, $destPath, $False, $transferOptions) $latestTransfer = $transferResult.Transfers | Sort-Object -Property @{ Expression = { (Get-Item $_.Destination).LastWriteTime } } ` -Descending | Select-Object -First 1