Re: Scripts for effectively Moving Files between SFTP/Local directory, but with directory masks
First, if you want to move files, use
https://winscp.net/eng/docs/library_session_getfilestodirectory
To limit the transfer to files in specific subfolders, use path filemask like
https://winscp.net/eng/docs/file_mask#path
https://winscp.net/eng/docs/rawtransfersettings#excludeemptydirectories
(untested)
Session.GetFiles
and Sessiopn.PutFiles
(or Session.GetFilesToDirectory
/Session.PutFilesToDirectory
) with remove
parameter set to true
, instead of Session.SynchronizeDirectories
.
https://winscp.net/eng/docs/library_session_getfilestodirectory
To limit the transfer to files in specific subfolders, use path filemask like
*/FromDMZ/*
and use "Exclude empty directories" to avoid "transferring" folders with no relevant files.
https://winscp.net/eng/docs/file_mask#path
https://winscp.net/eng/docs/rawtransfersettings#excludeemptydirectories
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.FileMask = "*/FromDMZ/*"
$transferOptions.AddRawSettings("ExcludeEmptyDirectories", "1")
$session.GetFilesToDirectory($remotePath, $localPath, $Null, $True, $transferOptions).Check()
(untested)