Topic "getting files and delete when confirmed"

Author Message
imcguinness
[View user's profile]

Joined: 2017-09-25
Posts: 2
Location: Newcastle
Hi,
I have a remote server that i need to download *.xml files in a folder and then delete those files from the server. The files can be added to the server by a separate process at any time so i only want to delete the ones i have downloaded correctly.

If i used the get command with the -delete option like this
Code:
get -delete *.xml d:\temp\
will it :
a) get file 1, then delete it on success, get file 2, delete it on success, etc
or
b) get *.xml, then delete *.xml ?
What i need to avoid is it getting *.xml, during which another .xml is created (but not downloaded), and then it getting deleted by the del *.xml
Also, say it had 10 files to get and it failed for file 6, would it try to delete it with the *.xml

The alternative path i was thinking is to run a script that lists all of the *.xml files, then a process (thinking a for /f command loop) to build a new script to get the listed files one at a time with -delete, and then run the new script. that way i'm only dealing with the named files from the first listing and each get -delete is only talking about 1 file at a time.

For reference i will be running this on Win Server 2012.

Any example snipets of code are always greatly appreciated. a very ruff outline of the list and loop option i was thinking is below.

Ian

Code:
####main.bat
cd "D:\Scripts"
subbat1.bat #make the list of files
subbat2.bat #for loop to build the get script
subbat3.bat #run the get script

####subbat1.bat
"C:\Program Files (x86)\WinSCP\WinSCP.exe" /log="D:\Scripts\WinSCP.log" /ini=nul /script="D:\Scripts\script1.txt"
##script1.txt
open ftp://user:password@203.57.8.137/ -rawsettings ProxyHost="10.83.75.3" ProxyPort=2121 ProxyUsername="user" FtpProxyLogonType=8 ProxyPassword="password"
cd /outgoing
lcd "D:\Scripts"
ls /outgoing/*.xml >"D:\Scripts\filelist.txt"
exit

####subbat2.bat
for /f command needed to build the script3.txt file

####subbat3.bat
"C:\Program Files (x86)\WinSCP\WinSCP.exe" /log="D:\Scripts\WinSCP.log" /ini=nul /script="D:\Scripts\script3.txt"
##script3.txt
open ftp://user:password@203.57.8.137/ -rawsettings ProxyHost="10.83.75.3" ProxyPort=2121 ProxyUsername="user" FtpProxyLogonType=8 ProxyPassword="password"
cd /outgoing
lcd "D:\xml_INBOUND"
get -delete file1 D:\xml_INBOUND\
get -delete file2 D:\xml_INBOUND\
get -delete file... D:\xml_INBOUND\
exit
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26890
Location: Prague, Czechia
This is what it does:
imcguinness wrote:
a) get file 1, then delete it on success, get file 2, delete it on success, etc
imcguinness
[View user's profile]

Joined: 2017-09-25
Posts: 2
Location: Newcastle
Thanks a lot.. that makes life a lot easier.
Ian
Advertisements

You can post new topics in this forum

Search

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License