Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

immortalstrong

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.
immortalstrong

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)