Topic "Synchronize file type in order - help needed"

Author Message
malva
[View user's profile]

Joined: 2014-10-24
Posts: 7
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.


Code:
    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
}
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25015
Location: Prague, Czechia
Use include file mask *.xml for the first step and exclude file mask |.xml for the second step.
See https://winscp.net/eng/docs/file_mask
_________________
Martin Prikryl
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