Post a reply

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)


Topic review


Re: Deleting files after transfer

Is it possible to do the same thing in script file?

This is my script file
# Automatically abort script on errors
option batch abort
# Disable overwrite confirmations that conflict with the previous
option confirm off
# connect as ftp
open "FTPOPEN"
# Force binary mode transfer
option transfer binary
# Change the remote directory
cd /.../
# Change the local directory
# Upload the file to current working directory
get /*.txt
# I want to delete files upload after the command GET
# Disconnect
# exit winscp


Deleting files after transfer

Hi all,

I'm using the following script to get files from SFTP. Everything is working great but now they came with a demand to delete the files on the source end after getting them.
Can someone help please.
Thanks in advance.
# Load WinSCP .NET assembly
Add-Type -Path "WinSCPnet.dll"
# Set up session options
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
    Protocol = [WinSCP.Protocol]::Sftp
    HostName = "***.***.**"
    PortNumber = 8330
    UserName = "****"
    Password = "****"
    SshHostKeyFingerprint = "ssh-rsa 4096 rEjkMymlF6K/u182f70hLa7a0r7pwDze5oBRa0dk62U="
$sessionOptions.AddRawSettings("FSProtocol", "2")
$session = New-Object WinSCP.Session
    # Connect
    # Transfer files
    $session.GetFiles("/*", "C:\Users\dady\Documents\*").Check()