xml#rm) ` (with ` remote ` and `
-delete  ` )

##  Examples

    
    
    [synchronize](https://winscp.net/eng/docs/scriptcommand_synchronize) both
    
    
    [synchronize](https://winscp.net/eng/docs/scriptcommand_synchronize) remote -delete d:\www /home/martin/public_html
    
    
    [synchronize](https://winscp.net/eng/docs/scriptcommand_synchronize) both -filemask="|*.bak; *.tmp"

##  Converting to .NET Assembly

When [ converting script to .NET Assembly ](/eng/docs/library_from_script) ,
map ` synchronize ` command to ` [ Session.SynchronizeDirectories
](/eng/docs/library_session_synchronizedirectories) ` method.

Parameters mapping: Command parameter ` local|remote|both ` maps to method
parameter ` mode ` , with values ` SynchronizationMode.Local ` , `
SynchronizationMode.Remote ` and ` SynchronizationMode.Both ` , respectively (
[ Enumeration syntax ](/eng/docs/library_powershell#enums) in PowerShell is
like ` [WinSCP.SynchronizationMode]::Local ` ). Command parameter ` local
directory ` maps to method parameter ` localPath ` . Command parameter `
remote directory ` maps to method parameter ` remotePath ` . You have to [
convert relative paths to absolute paths
](/eng/docs/library_from_script#paths) .

Switches mapping:

Switch  |  Mapping   
---|---  
` -preview ` |  Use [ ` Session.CompareDirectories ` method ](/eng/docs/library_session_comparedirectories) instead of ` Session.SynchronizeDirectories ` .   
` -delete ` |  Value ` true ` ( ` $True ` in PowerShell) for method parameter ` removeFiles ` .   
` -mirror ` |  Value ` true ` ( ` $True ` ) for method parameter ` mirror ` .   
` -criteria ` |  Set method parameter ` criteria ` . Use ` SynchronizationCriteria.Time ` for ` time ` , ` SynchronizationCriteria.Size ` for ` size ` , ` SynchronizationCriteria.Checksum ` for ` checksum ` and ` SynchronizationCriteria.None ` for ` none ` .   
[ Enumeration syntax ](/eng/docs/library_powershell#enums) in PowerShell is
like ` [WinSCP.SynchronizationCriteria]::Time ` .  
` -permissions `  
` -nopermissions `  
` -transfer `  
` -filemask `  
` -resumesupport `  
` -speed=<kbps> ` |  [ Converting transfer settings scripting switches ](/eng/docs/library_from_script_transfer_settings) to .NET assembly class ` TransferSettings ` .   
  
To emulate the ( [ default ](/eng/docs/scripting#using_scripting) ) ` [ option
batch abort ](/eng/docs/scriptcommand_option#batch) ` mode, call ` [
TransferOperationResult.Check ](/eng/docs/library_operationresultbase) ` on
method’s result. See also [ Capturing results of operations
](/eng/docs/library_session#results) .

For example, following script snippet:

    
    
    [synchronize](https://winscp.net/eng/docs/scriptcommand_synchronize) both d:\www /home/martin/public_html

_Advertisement_

maps to following [ PowerShell ](/eng/docs/library_powershell) code:

    
    
    $synchronizationResult =
        $session.SynchronizeDirectories(
            [WinSCP.SynchronizationMode]::Both, "d:\www", "/home/martin/public_html", $False)
    # Throw on any error to emulate the (default) "option batch abort" mode
    $synchronizationResult.Check()

##  Contribute

![PayPal](https://winscp-
static-746341.c.cdn77.org/assets/images/paypal.svg?v=7032)

[ Donate ](/eng/donate.php)

  * [ $9 ](/eng/donate.php?amount=9&currency=USD&class=S "Donate $9 via PayPal")
  * [ $19 ](/eng/donate.php?amount=19&currency=USD&class=S "Donate $19 via PayPal")
  * [ $49 ](/eng/donate.php?amount=49&currency=USD&class=S "Donate $49 via PayPal")
  * [ $99 ](/eng/donate.php?amount=99&currency=USD&class=S "Donate $99 via PayPal")

![Visa](https://winscp-static-746341.c.cdn77.org/assets/images/card-logo-
visa.svg?v=7032) ![Mastercard](https://winscp-
static-746341.c.cdn77.org/assets/images/card-logo-mastercard.svg?v=7032)
![American Express](https://winscp-
static-746341.c.cdn77.org/assets/images/card-logo-amex.svg?v=7032)
![Other](https://winscp-static-746341.c.cdn77.org/assets/images/card-logo-
unknown.svg?v=7032)

##