Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: Session.SynchronizeDirectories Method Powershell not removing remote files

rfiscus wrote:

Where in PowerShell would I add removeFiles?

The PowerShell example you have referred to yourself passes a $False value to the removeFiles argument:
https://winscp.net/eng/docs/library_session_synchronizedirectories#powershell

$synchronizationResult = $session.SynchronizeDirectories(
[WinSCP.SynchronizationMode]::Remote, "d:\www",
"/home/martin/public_html", $False)

I assume you just want to replace it with $True.
sd-guest

I was referring to the post of martin and his suggestion. I have not checked the script itself.

That tries to delete the remote files instead of the local files that were just copied to the remote server.


Isn't it that what you wanted?

It does not seem to remove remote files if they are no longer on the local server. How can I make it also remove the remote files if they no longer exist locally?
rfiscus

sd-guest wrote:

Please check $session.SynchronizeDirectories in the script. First parameter is the sync mode, second is local path, third is remote path, and then removeFiles, which is $False in the example script. When I got that right, the latter should be changed to $True.


That tries to delete the remote files instead of the local files that were just copied to the remote server.
sd-guest

Please check $session.SynchronizeDirectories in the script. First parameter is the sync mode, second is local path, third is remote path, and then removeFiles, which is $False in the example script. When I got that right, the latter should be changed to $True.
rfiscus

Session.SynchronizeDirectories Method Powershell not removing remote files

The functions listed are for C# and VB.net, I don't see the syntax of the function to add it to the PowerShell script. If you are saying I can use the C# or VB.net function from within the PowerShell version, where would I place the function[/code]?
C#
public SynchronizationResult SynchronizeDirectories(

    SynchronizationMode mode,
    string localPath,
    string remotePath,
    bool removeFiles,
    bool mirror = false,
    SynchronizationCriteria criteria = SynchronizationCriteria.Time,
    TransferOptions options = null
)


Where in PowerShell would I add removeFiles?
martin

Re: Session.SynchronizeDirectories Method Powershell not removing remote files

I do not understand. The method is just one. There are no variants for different languages.
rfiscus

Re: Session.SynchronizeDirectories Method Powershell not removing remote files

martin wrote:

Did you set the removeFiles argument to true?


How, I don't see that option in PowerShell, only the other languages?
martin

Re: Session.SynchronizeDirectories Method Powershell not removing remote files

Did you set the removeFiles argument to true?
rfiscus

Session.SynchronizeDirectories Method Powershell not removing remote files

I am using the PowerShell version of Session.SynchronizeDirectories Method located at https://winscp.net/eng/docs/library_session_synchronizedirectories#powershell
It all works really well for new files that need to be uploaded to the remote server. It does not seem to remove remote files if they are no longer on the local server. How can I make it also remove the remote files if they no longer exist locally?