Search code examples
scriptingsftpwinscp

Avoid downloading subfolders with WinSCP


I am using the below script

option batch abort
option confirm off
open sftp:-------
get -filemask=">=%TIMESTAMP#yyyy-mm-dd%" /outbound \\sharedrive\Copiedfiles
exit

Please let me know how I can copy only files, but not subfolders.

The SFTP folder /outbound contains csv files and other subfolders like edi, test, debug.

The CSV files are placed daily and these folders also get updated daily.

Please let me know how I can copy only the .csv files (I tried options but was not successfully).


Solution

  • See How do I transfer directory non-recursively?

    So in your case, you add |*/ to your existing file mask:

    get -filemask=">=%TIMESTAMP#yyyy-mm-dd% | */" /outbound \\sharedrive\Copiedfiles