Help with script to FTP all files in a local folder to a remote server then delete the local files

Advertisement

JW_PPCGroup
Joined:
Posts:
2
Location:
Virginia

Help with script to FTP all files in a local folder to a remote server then delete the local files

I'm having trouble with what should probably be a simple operation.
Background.
I have a server(A) generating logs behind a data diode. The logs are sent through the data diode to another local server(B) which will FTP any received logs to a remote FTP server. Once FTP transfer is completed then server(B) will delete the transmitted log file locally.
The script will be run via Windows Scheduled Tasks every 10 min.
  1. Check for new complete files (no partials) in local folder, if none then end script.
  2. If new files exist then FTP all new files to remote server directory.
  3. Delete newly uploaded files in local directory then end script.
Not sure how to avoid deleting any files that were arriving as or after script was started.
New to WinSCP & scripting but it seems to be a fairly common task. Maybe there is some premade subscripts I could piece together into a new script.
Last edited by JW_PPCGroup on 2022-09-08 12:54; edited 1 time in total

Reply with quote

Advertisement

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

Re: Help with script to FTP all files in a local folder to a remote server then delete the local files

That's what -delete does:
put -delete *

Though this won't cover the 1. It is rather vague requirement anyway. Not sure what you exactly mean by it.

Reply with quote

JW_PPCGroup

Actually I was hoping someone already had a script written since I think it's a fairly generic task. I've been tasked with figuring it out though I haven't any WinSCP experience.

Reply with quote

Advertisement

You can post new topics in this forum