Hello all
I am trying to include files less than a day old and exclude files that contain
Merge
using the following WinSCP PowerShell script. Is there something I can rewrite to have both masks work every time please? Let me know if you need any further info.
Thanks
# Connect
$session.Open($sessionOptions)
$emailBody += "`n[$(get-date -f G)] Session opened"
# Transfer files
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.FileMask = "|*_Merges_*;<1D";
In the log files in test using a handpicked selection of files this seems to work, as follows
. 2024-04-16 10:04:05.876 Transfer done: 'D:\ftp\Oxleas\RiO_Admissions_OXLEAS_20240415211802.CSV' => '/oxleasRIO/RiO_Admissions_OXLEAS_20240415211802.CSV' [11512] Less than day old ok
. 2024-04-16 10:04:05.876 Deleting successfully uploaded source file "D:\ftp\Oxleas\RiO_Admissions_OXLEAS_20240415211802.CSV".
. 2024-04-16 10:04:05.891 File "D:\ftp\Oxleas\RiO_Alerts_OXLEAS_20240413211801.CSV" excluded from transfer
* 2024-04-16 10:04:05.891 (ESkipFile) older than a day skipped
. 2024-04-16 10:04:05.891 File "D:\ftp\Oxleas\RiO_Alerts_OXLEAS_20240414211802.CSV" excluded from transfer
* 2024-04-16 10:04:05.891 (ESkipFile) older than a day skipped
. 2024-04-16 10:04:05.891 File "D:\ftp\Oxleas\RiO_Merges_OXLEAS_20240409211801.CSV" excluded from transfer
* 2024-04-16 10:04:05.891 (ESkipFile) filename contains merge skipped
However in live using the same script on the same server with live data feed
Merges
are skipped but old files are not
. 2024-04-17 07:15:51.658 File "D:\ftp\Oxleas\RiO_Merges_OXLEAS_20240416211801.CSV" excluded from transfer
* 2024-04-17 07:15:51.658 (ESkipFile) merge skipped
. 2024-04-17 07:15:51.658 File: 'D:\ftp\Oxleas\RiO_MHCareCoordinator_OXLEAS_20240203211801.CSV' [2024-04-17T06:04:34.399Z] [32]
. 2024-04-17 07:15:51.658 Copying "D:\ftp\Oxleas\RiO_MHCareCoordinator_OXLEAS_20240203211801.CSV" to remote directory started.
---
< 2024-04-17 07:15:51.674 Status code: 0
. 2024-04-17 07:15:51.674 Transfer done: 'D:\ftp\Oxleas\RiO_MHCareCoordinator_OXLEAS_20240203211801.CSV' => '/oxleasRIO/RiO_MHCareCoordinator_OXLEAS_20240203211801.CSV' [32] unwanted old file copied
. 2024-04-17 07:15:51.674 Deleting successfully uploaded source file "D:\ftp\Oxleas\RiO_MHCareCoordinator_OXLEAS_20240203211801.CSV".