Directorymask problem

Advertisement

Jaroslav Vrbka
Joined:
Posts:
1

Directorymask problem

Dear all,

there is an option to download only directories older than, for example, 3 days?

At source are placed only directories like
2017-11-26T0630+0000
2017-11-25T0630+0000
2017-11-24T0630+0000
2017-11-23T0630+0000
...

I want to download only the 3 youngest.

If I use the options below, I will not download any directory.

Dim transferOptions As New TransferOptions
transferOptions.TransferMode = TransferMode.Binary
transferOptions.PreserveTimestamp = False
transferOptions.ResumeSupport.State = TransferResumeSupportState.Off
transferOptions.FileMask = "*/<3D"

If I use the options transferOptions.FileMask = "*/" I will download all directory.

Is there any possibility to reach my request using a filemask options?
If not how I can achieve it?

Thank you very much for your help
Jaroslav

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,442
Location:
Prague, Czechia

Re: Directorymask problem

Jaroslav Vrbka wrote:

At source are placed only directories like
2017-11-26T0630+0000
2017-11-25T0630+0000
2017-11-24T0630+0000
2017-11-23T0630+0000
As these last modification timestamps or directory names?

Reply with quote

Guest

Re: Directorymask problem

martin wrote:

Jaroslav Vrbka wrote:

At source are placed only directories like
2017-11-26T0630+0000
2017-11-25T0630+0000
2017-11-24T0630+0000
2017-11-23T0630+0000
As these last modification timestamps or directory names?

Sorry for late answer.
The above are directory names.
The modification timestamps are similar.
26.11.2017 7:30:25
25.11.2017 7:30:36
...

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,442
Location:
Prague, Czechia

Re: Directorymask problem

Time constraints do not work for folders.

But you can easily code the same in VB.NET:

Dim newFolders As IEnumerable(Of RemoteFileInfo) =
    session.ListDirectory(sourceRemotePath).Files.Where(
        Function(fileInfo) fileInfo.LastWriteTime >= Date.Now.AddDays(-3))
 
For Each newFolder In newFolders
    session.GetFiles(newFolder.FullName, targetLocalPath).Check()
Next

Reply with quote

Guest

Re: Directorymask problem

martin wrote:

Time constraints do not work for folders.

But you can easily code the same in VB.NET:

Dim newFolders As IEnumerable(Of RemoteFileInfo) =
    session.ListDirectory(sourceRemotePath).Files.Where(
        Function(fileInfo) fileInfo.LastWriteTime >= Date.Now.AddDays(-3))
 
For Each newFolder In newFolders
    session.GetFiles(newFolder.FullName, targetLocalPath).Check()
Next

Jaroslav wrote:

Thanks your your answer.
I had to modify the code slightly so that the contents of the 3 downloaded directories were stored in separate directories and not overwritten in the root.
Below is a modified function code
Jaroslav

Dim newFolders As IEnumerable(Of RemoteFileInfo) =
    session.ListDirectory(sourceRemotePat).Files.Where(
    Function(fileInfo) fileInfo.LastWriteTime >= Date.Now.AddDays(-3))
For Each newFolder In newFolders
    If Not newFolder.FullName = "/." Then
        session.GetFiles(newFolder.FullName, targetLocalPath & "\" & newFolder.FullName.Replace("/", "")).Check()
    End If
Next

Reply with quote

Advertisement

You can post new topics in this forum