The Powershell script is trying to keep a local folder synched with a remote one, which is daily updated by operators.
This is the "hot" part
# Transfer options
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.FileMask = "* . m p 3>20K" // without spaces
# Synchronize files
$synchronizationResult = $session.SynchronizeDirectories([WinSCP.SynchronizationMode]::Local, $syncPath, $remotePath, $True, $transferOptions)
Since some of them are probably working from Mac it may happen that they copy rubbish files apart from needed m p 3 files.
I was able to see two kind of rubbish files:
1) Ghost copies of 1-2 kB of original m p 3, which I am able to ignore by masking for size > 20kB. However this kind of file is not blocking the synch process.
2) .DS_Store files, that should be a folder-related property file. If this file is inside the folder the script cannot parse the content anymore, blocking the synch process.