getting files and delete when confirmed

Advertisement

imcguinness
Joined:
Posts:
2
Location:
Newcastle

getting files and delete when confirmed

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
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

####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

Reply with quote

Advertisement

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

Re: getting files and delete when confirmed

This is what it does:

imcguinness wrote:

a) get file 1, then delete it on success, get file 2, delete it on success, etc

Reply with quote

Advertisement

You can post new topics in this forum