FTP batch top move (append) to a single remote filename
Posted: 17 Sep 2010 09:40
I am attempting to create an export batch file that will FTP several small .txt files to a single file on a remote ftp server. I created a batch file that seems to work in testing although I have concerns with loosing data if the batch runs and the ftp is unavailable. Is there a better way to script this?
The .txt files are named based on the date/time eg. 083010081040.txt and are exported on a scheduled basis. I was looking for something to add to windows scheduler but was concerned about data lose.
Any assistance would be welcome.
Thank you - Matt
:Archive
@ECHO '
@ECHO ' Beginning Archive Process
@ECHO '
IF NOT EXIST .\ARCHIVE MD .\ARCHIVE
COPY *.TXT .\ARCHIVE
COPY *.TXT TKTULOADP.DAT
:FTP
@ECHO '
@ECHO ' Beginning FTP Transfer Process
@ECHO '
> DataTran.ftp ECHO user
>>DataTran.ftp ECHO ftppass
>>DataTran.ftp ECHO hash
>>DataTran.ftp ECHO append TKTULOADP.DAT OSMDCSDB\TKTULOADP
>>DataTran.ftp ECHO quit
@ftp -v -i -s:DataTran.ftp 10.20.30.13
echo %errorlevel%
pause
IF %errorlevel% > 0 GOTO EOF
DEL *.txt
:EOF
The .txt files are named based on the date/time eg. 083010081040.txt and are exported on a scheduled basis. I was looking for something to add to windows scheduler but was concerned about data lose.
Any assistance would be welcome.
Thank you - Matt
:Archive
@ECHO '
@ECHO ' Beginning Archive Process
@ECHO '
IF NOT EXIST .\ARCHIVE MD .\ARCHIVE
COPY *.TXT .\ARCHIVE
COPY *.TXT TKTULOADP.DAT
:FTP
@ECHO '
@ECHO ' Beginning FTP Transfer Process
@ECHO '
> DataTran.ftp ECHO user
>>DataTran.ftp ECHO ftppass
>>DataTran.ftp ECHO hash
>>DataTran.ftp ECHO append TKTULOADP.DAT OSMDCSDB\TKTULOADP
>>DataTran.ftp ECHO quit
@ftp -v -i -s:DataTran.ftp 10.20.30.13
echo %errorlevel%
pause
IF %errorlevel% > 0 GOTO EOF
DEL *.txt
:EOF