Avoiding 0 kb files using (get -delete)

Advertisement

TOYO
Guest

Avoiding 0 kb files using (get -delete)

Hello WinSCP scripting guru!

I am using a following script to get xml files from FTP server to a local folder on one of the servers on the perimeter network.
option batch on
option confirm off
open ftp://ftpname:password@xx.xxx.xxx.xxx
cd EXAM\IN
option transfer binary
get -delete 1122result_*.xml \\servername\data\FTP\
close
exit
The script is working, getting file by file from FTP and deleting pulled file on FTP.
The files on FTP are pushed by a third party vendor with a real time schedule.
Sometimes i am getting 0 kb files from FTP because script starts the same time vendor pushed the file. Because script deleting file by file right after GET, i can't use a masking for the file size.

How to accomplish the same logic (get file by file with delete option on FTP) but avoid a 0 kb files?

Thank you so much,

You�re TOYO.

Reply with quote

Advertisement

TOYO
Guest

Re: Avoiding 0 kb files using (get -delete)

prikryl, the option exclude <1 ignoring by get -delete.

The exclude and include options working only (not with -delete).
Do you have an alternative to this solution?

You're TOYO.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,441
Location:
Prague, Czechia

Re: Avoiding 0 kb files using (get -delete)

You are right, I've forgot about this.

Well, you can enable XML logging, use just get then parse the XML log to see what file got downloaded and generate another script to delete those files.

See this example script (for completely different task), which shows you how to parse the XML log to get filenames and how to generate script.

EDIT (2021): The -delete now works with -filemask. For advanced code, you can now also use WinSCP .NET assembly instead, as the updated article linked above shows.

Reply with quote

Advertisement

You can post new topics in this forum