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

matrixtan

How to delete all files in the folder located on a SFTP site using Excel VBA?

What is the code to use?
My folder is name is SCB.
martin

Re: Issues with Winscp PUT -Delete option

I have sent you an email with a debug version of WinSCP to address you have used to register on this forum.
kumar.kk

Issues with Winscp PUT -Delete option

There is no other process to delete the file in the local directory except the SFTP script which has PUT -Delete option.
martin

Re: Issues with Winscp PUT -Delete option

kumar.kk wrote:

we even tried to trigger the script only when the file is present in folder.

How do your check that?
Isn't there any other process that might delete the file, after you test file existence, but before you run WinSCP?

Is there any other way to transfer files to remote server and delete the local files using batch script.

Your code is correct, there's nothing to be done differently.
kumar.kk

Issues with Winscp PUT -Delete option

Thanks for the reply prikryl. we even tried to trigger the script only when the file is present in folder. we have this issue for only 1 or 2 files a day. Is there any other way to transfer files to remote server and delete the local files using batch script.
martin

Re: Issues with Winscp PUT -Delete option

WinSCP does not delete the local file, if the upload fails.
So I actually believe the file did not exist already at the time the upload started, hence the error message.
kumar.kk

Issues with Winscp PUT -Delete option

Hi,

I have the below script to transfer files to remote server(Unix) and then delete the files in the local directory. But once in a day we are seeing the below error.
"Script: System Error. Code: 2.
The system cannot find the file specified"
1 out of 100 files was not copied to the remote directory and is also being deleted from the local folder. can someone please help me to know if there is a way to NOT delete the file if it was not transferred to the remote server.

we are using WinSCP Version 5.1.7(Build 3446)

Here is the batch script that runs every one minute.
@echo off
start winscp /console /script="C:\CDI\SFTP.txt" /log=SFTP.Log

---------SFTP.txt-----------
option batch abort
option confirm off
open sftp://user:password@HostName -hostkey="ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:x:xx:xx:xx"
lcd C:\input\
cd inbound
option transfer binary
put -delete File_20141214230801099.txt
chmod 777 File_20141214230801099.txt
close
exit
---------*******-----------



Thanks
Kumar