Post a reply

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

Optimaximal

Fair enough - I missed the second $False off my script from when I previously had the Sync Criteria entry.
martin

Re: Issues with Synchronisation & FileMask

TransferOptions is 7th argument of Session.SynchronizeDirectories method:
https://winscp.net/eng/docs/library_session_synchronizedirectories


# Synchronize files to local directory, collect results
$synchronizationResult = $session.SynchronizeDirectories(
[WinSCP.SynchronizationMode]::Local,
$localPath,
$remotePath,
$False,
$False,
[WinSCP.SynchronizationCriteria]::Time,
$transferOptions
)


See https://winscp.net/eng/docs/faq_library_parameters
Optimaximal

Ok, further research tells me that using asterisk will collect any files with either the former or latter item.

How do you use EscapeFileMask in the context of directory synchronisation?
Optimaximal

Issues with Synchronisation & FileMask

As part of a SQL Server SSIS package, I'm attempting to download files from an FTPS source using a combination of Powershell and the WinSCP .NET Assembly.

I've used it elsewhere just fine, but I'm having issues making the file mask work correctly with Synchronisation.

The files on the FTP are of a format AA_Unsubscribes_Timestamp.txt, where AA is a collection of letters that could be anything, defined earlier in the SSIS package.

I have the following on a try catch loop in the powershell script:

$session = New-Object WinSCP.Session


# Connect to Remote Server, download files and remove
try
{
   # Connect
   $session.Open($sessionOptions)

   # Set up transfer options
   $transferOptions = New-Object WinSCP.TransferOptions -Property @{
      TransferMode = [WinSCP.TransferMode]::Automatic
      FileMask = "CF_Unsubscribes_*.txt"
   }
   
   # Synchronize files to local directory, collect results
   $synchronizationResult = $session.SynchronizeDirectories(
      [WinSCP.SynchronizationMode]::Local,
      $localPath,
      $remotePath,
      $False,
      $transferOptions
   )
}
catch
{
exit 1
}
Finally
{
$session.Dispose()
}


Unless I'm misreading it, this should only pull down the files beginning with, for example, CF. As it stands, it's pulling down every file, regardless of the mask.

Am I doing something extremely dense?

Edit - The WinSCP Log File attached.