Directory Transfer: Multiple file mask

Advertisement

Andres
Guest

Directory Transfer: Multiple file mask

Hi guys. Thanks for this awesome library :) it's helping a lot.

I'm working with VS2015 C# and I have following code.

// Upload files
TransferOptions transferOptions = new TransferOptions();
transferOptions.TransferMode = tmde;
// that will contain "*.jpg;|*/"; 
transferOptions.FileMask = jsonConfig.files_mask;
 
SynchronizationResult syncResult =
    session.SynchronizeDirectories(
        SynchronizationMode.Remote,
        jsonConfig.local_path,
        jsonConfig.remote_path,
        false,
        false,
        SynchronizationCriteria.None,
        transferOptions);
But sadly it works only with the last or only one file mask.
Is there any way to add more than one?

Thanks in advance.

Reply with quote

Advertisement

Andres
Guest

Thanks Martin, now I get it.

If anyone is interested, This make the trick to filter by file type and exclude sub folders:
*.jpg |  */

For instance:
transferOptions.FileMask = jsonConfig.files_mask + " | */";

Reply with quote

Jovy
Guest

How to transfer multiple file types

Hi,

I've succeeded to transfer one file type but how do I code it in script and batch file? For instance I need to transfer both csv and txt file? How should I append it.

Reply with quote

Advertisement

TPyne
Joined:
Posts:
2

Can it work with -delete

I process several files with WinSCP however somehow a few a locked on the other server which belongs to another company. So they do not delete when I use the command
get *.bt -delete
This means not only does it not process past the locked file it keeps downloading it over and over.

I tried get *.bt -delete |PCID* and even -delete |PCID*.bt but then it says it cannot get the file information.

Any ideas.

I've reached out to the other company to manually delete the file but they can take days. I've used WinSCP and several other FTP clients to delete this file and get a 550 error.

The irony is the file was generated by the other company. We would normally download it and process it but since it is locked somehow we cannot. It would just process the same file over and over.

This script has been running for a few years now and until today no issues.

Is there a way I can ignore a specific filename but still have the -delete switch. We have to delete the files we pull down.

Reply with quote

TPyne
Joined:
Posts:
2

Sadly no

Sadly no. It still tries to transfer the file which makes no sense.

I tried making it go after a certain date because the new files are not locked but then it gave some message about merging files together,
get Generate*.bt    -delete   >2024-03-04
This tried to merge all the files together. It also did not delete them.

To work around it I wrote get statements for each of the valid file prefixes. We will just handle the others manually on request. It's a pain but after that last one I can't risk losing files on our system because the program decided to merge them together.

Reply with quote

Advertisement

t51
Guest

Exclude Multiple Folders from transferlist

I have a session whose root directory contains multiple folder and file. I want to exclude two directories from transferring from the server directory.

Let's say /server/path/one and /server/path/two.

I am using the WinSCP NuGet package in VB.NET framework. Currently the code is as follows
Dim transferOptions As New TransferOptions
transferOptions.TransferMode = TransferMode.Binary
transferOptions.FileMask = $"/server/path/one/;/server/path/two/ | */"
transferOptions.AddRawSettings("NewerOnly", "1") 
 
Dim transferResult As TransferOperationResult
transferResult = session.GetFiles($"{ServerDirectory}", $"{ClientDirectory}", False, transferOptions)
but when it runs it return empty directories and does not transfer any of the file in neither the base nor the sub directories

Reply with quote

Advertisement

You can post new topics in this forum