Synchronize file type in order - help needed

Advertisement

malva
Joined:
Posts:
7

Synchronize file type in order - help needed

Hi!

I'm synchronizing directories and all works fine but I need help.
I would like to download (synchronize) first all files that are NOT .xml and then download remaining .xml files.
Anybody could help me. Please.

m.


    Try
    {
        # Connect
        $session.Open($sessionOptions)

        $localPath = "E:\test\import"
        $remotePath = "/"

        # Synchronize files to local directory, collect results
        $synchronizationResult = $session.SynchronizeDirectories(
            [WinSCP.SynchronizationMode]::Local, $localPath, $remotePath, $False, $False, [WinSCP.SynchronizationCriteria]::Time, $transferOptions)


        foreach ($download in $synchronizationResult.Downloads)
        {
            # Success or error?
            if ($download.Error -eq $Null)
            {
                Write-Host ("Download of {0} succeeded, removing from source" -f
                    $download.FileName)
                # Download succeeded, remove file from source
                $removalResult = $session.RemoveFiles($session.EscapeFileMask($download.FileName))
 
                if ($removalResult.IsSuccess)
                {
                    Write-Host ("Removing of file {0} succeeded" -f
                        $download.FileName)
                }
                else
                {
                    Write-Host ("Removing of file {0} failed" -f
                        $download.FileName)
                }
            }
            else
            {
                Write-Host ("Download of {0} failed: {1}" -f
                    $download.FileName, $download.Error.Message)
            }
        }
    }
    finally
    {
        # Disconnect, clean up
        $session.Dispose()
    }
 
    exit 0
}
catch [Exception]
{
    Write-Host $_.Exception.Message
    exit 1
}

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum