3

I need to be able to upload a local folder (created daily) to a remote FTP everyday.

I’ve messed with WinSCP file masks (i.e. put -filemask="*>=today" C:\local\ /) and ran into issues where it would upload the latest folder (contained subfiles) but it would also upload the rest of the folders in the directory. (they were empty) I then realized filemasks only works specifically for files, not folders.

I then came across this thread: Download files newer than X days from SFTP server with WinSCP, skipping folders that do not contain any matching files

  • User had the same issue except he was going Remote -> Local whereas I need the opposite, solution was to use PowerShell

Considering that thread is a couple years old, does WinSCP scripting now support such a feature? Unfortunately I’m a bit of a novice with PowerShell.

Thanks for your time.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
kost82
  • 33
  • 3

1 Answers1

1

WinSCP does not support time constraints for folders.

But what has changed (since the other question) is that now you can prevent WinSCP from creating the empty folders. Use -rawtransfersettings switch with ExcludeEmptyDirectories setting.

put -rawtransfersettings ExcludeEmptyDirectories=1 -filemask="*>=today" C:\local\ /

If you really need to upload the latest folder (as opposite to uploading the folder with the latest files), using WinSCP .NET assembly from your favourite language (like PowerShell) is still the way to go, as shown in the other question.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992