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

tom-iot

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
}
tom-iot

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