remember downloaded files - filemask - RESOLVED

Advertisement

blie
Joined:
Posts:
2
Location:
NL

remember downloaded files - filemask - RESOLVED

Update2 RESOLVED!:
Already fixed :-)!

Added following variable:
$wildcard = "*.csv"
Adjusted following lines:
Write-Host "Looking for new files..."
$files =
    $session.EnumerateRemoteFiles(
        $remotePath, $wildcard, [WinSCP.EnumerationOptions]::None)
This fixed the issue!

Update1:

Adjusting the following line helped a bit, but the FileMask isn't working.
$session.GetFiles($source, $localFilePath, $False, $transferOptions).Check()

Filemask looks like this now:
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.ResumeSupport.State = [WinSCP.TransferResumeSupportState]::On
$transferOptions.TransferMode = [WinSCP.TransferMode]::Binary
$transferOptions.FileMask = "*.csv; /PATH1/ | */"

Hi all,

What I'm trying to do is:
Download files from a remote sftp server to local, so the situation is as follow:
local path: c:\path
remote path: /FILES1/ (do not recurse, only include this directory, not subdirectory's)
filetype: *.csv

So what I did, I've used the example script from Martin and adjusted it a bit:

Inserted:
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.ResumeSupport.State = [WinSCP.TransferResumeSupportState]::On
$transferOptions.FileMask = "*.csv | */"

I am running the script with the following command:
powershell.exe -File C:\path\DownloadNewFilesAno.ps1 -sessionUrl "sftp://username:password@fqdn.com/" -localPath "C:\path" -remotePath "/FILES1" -listPath "C:\path\downloaded.txt"
But the script just keeps downloading also the files from the subfolders, so it looks like the transferoptions isn't working, also when I change *.csv to *.bat it still downloads CSV files.

The complete script is added. Please, can someone help me out what I'm doing wrong? Do I need to call $transferoptions somewhere else?
Description: The script!

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum