Re: Sync only level 1 directory issue
Do I understand right, that it's taking too long, because finding the new files itself takes too long already. Right?
WinSCP does not support time constraints for directories. So this is not doable using a file mask only.
But you can identify folder candidates programmatically and run separate synchronizations just for those.
Untested!
WinSCP does not support time constraints for directories. So this is not doable using a file mask only.
But you can identify folder candidates programmatically and run separate synchronizations just for those.
# List files
$directoryInfo = $session.ListDirectory("/remote/path")
# Find recent folders
$limit = (Get-Date).AddDays(-15)
$recentFolders =
$directoryInfo.Files |
Where-Object { $_.IsDirectory } |
Where-Object { $_.LastWriteTime -gt $limit }
# Synchronize them
foreach ($recentFolder in $recentFolders)
{
$localPath = "C:\local\path\" + $recentFolder.Name
New-Item -ItemType Directory -Force -Path $localPath | Out-Null
$session.SynchronizeDirectories(
[WinSCP.SynchronizationMode]::Local, $recentFolder.FullName,
$localPath, $False).Check()
}
Untested!