modifying sample script to remove file immediately after successful transfer

Advertisement

tom-iot
Joined:
Posts:
2

modifying sample script to remove file immediately after successful transfer

Howdy!

We run this script on a gateway that resets often. So we need the script to remove the file soon after the transfer, and not after the queue was processed.

Because if the gateway resets while the transfer is happening, next time all the files will still be in the folder, even the ones that were uploaded.

this is the script that we use:

https://winscp.net/eng/docs/script_local_move_after_successful_upload

Reply with quote

Advertisement

tom-iot
Joined:
Posts:
2

Hi

Thanks for the tip, meantime a developer friend pointed me in the right direction:

https://winscp.net/eng/docs/library_session_putfiles

Adding 'true' to PutFiles deletes the file after upload


    try
    {
        # Connect
        $session.Open($sessionOptions)
 
        # Upload file, delete when successful

        $transferResult = $session.PutFiles($localPath, $remotePath,$true)
 
           }
    finally
    {
        # Disconnect, clean up
        $session.Dispose()
    }
 
    exit 0
}
catch
{
    Write-Host "Error: $($_.Exception.Message)"
    exit 1
}

Reply with quote

Advertisement

You can post new topics in this forum