Topic "Select only specific-format files in subfolders, then download them"

Author Message
Coraz
[View user's profile]

Joined: 2016-03-02
Posts: 3
First I'd like to say that it's the first time I'm trying to create a script, and I'm not a native English speaker, so learning a programming language like C# can be difficult for me.

What I'm trying to do is choose a directory (that much I can manage on my own), list all the files in the folder and the subfolders in the format .doc or .docx, then download them without regards to folder structure (I just want the files, not the folders). I figured after a bit of search that I would need .NET Assembly Line to accomplish this. Looking a bit around in this forum I found https://winscp.net/forum/viewtopic.php?t=14392, but I can't figure out a way to insert a filemask (or where to put it) and the pass the list output to the .NET equivalent of
Code:
mget
(I think I need to use this).

Could someone help me?
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24991
Location: Prague, Czechia
So what language are you coding this in? C# or PowerShell?
Coraz
[View user's profile]

Joined: 2016-03-02
Posts: 3
I think C# would be better, but correct me if I'm mistaken, I'm just a beginner after all.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24991
Location: Prague, Czechia
This would do:

Code:
TransferOptions transferOptions = new TransferOptions();
transferOptions.FileMask = "*.doc;*.docs";
session.GetFiles("/remote/path/*", @"c:\local\path\", false, transferOptions).Check();
Coraz
[View user's profile]

Joined: 2016-03-02
Posts: 3
Thanks Smile
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License