Exclude Mask not working

Advertisement

immortalstrong
Joined:
Posts:
2

Exclude Mask not working

Using WINSCP powershell, I'm trying to download files from SFTP then delete the files from the SFTP source once the files are downloaded.

However, the exclude mask doesn't seem to work. I'm trying to exclude subfolders from the root using the following masks:
"*.csv|*/"
or
"|*/"

CSV files to be downloaded are on /testroot.
I want to exclude the folder /testroot/testarchive and its contents from being downloaded.
However, /testarchive and its contents are still being downloaded.

Snippet of the code:
param (
    $localPath = "C:\summit\FXGo\FileInput\",
    $remotePath = "/testroot/"
)
 
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.FileMask = "*.csv|*/"
$session = New-Object WinSCP.Session
try
{
    # Connect
    $session.Open($sessionOptions)
    $synchronizationResult = $session.SynchronizeDirectories([WinSCP.SynchronizationMode]::Local, $localPath, $remotePath, $transferOptions)

Reply with quote

Advertisement

immortalstrong
Joined:
Posts:
2

Exclude Mask not working

This is now working. Reference: https://winscp.net/forum/viewtopic.php?t=15545

I've changed the following:

From:
$synchronizationResult = $session.SynchronizeDirectories(
    [WinSCP.SynchronizationMode]::Local, $localPath,
    $remotePath, $transferOptions)
To:
$synchronizationResult = $session.SynchronizeDirectories(
    [WinSCP.SynchronizationMode]::Local, $localPath,
    $remotePath, $false, $false, [WinSCP.SynchronizationCriteria]::Time,  $transferOptions)
As mentioned in https://winscp.net/eng/docs/faq_library_parameters.

Reply with quote

Advertisement

You can post new topics in this forum