Batch download file _dos/bat before the specified number of minutes on the FTP server

Source: Internet
Author: User
Tags goto
@echo off rem Specify FTP user name set ftpuser=xxx REM Specify FTP password set ftppass=xxxxxxx REM Specify FTP server address set ftpip=xxx.xxx.xxx.xx rem specify what to download Where the file is located in the FTP server set Ftpfolder=/export/home/prod/ntcdata REM specifies where to store files downloaded from FTP to where set downfolder=e:/rem specifies download a few minutes before the file set Minsago=60 set Ftpdir=%temp%/tempdir2.txt set Ftpdown=%temp%/tempdown2.txt REM assumes that the native date time format is YYYY-MM-DD hh:nn:ss set Filey =%date:~0,4% if%time:~0,2% LSS (set hh=0%time:~1,1%) Else (set hh=%time:~0,2%) call:D atetomins%date:~0,4%%date:~5,2

%%date:~8,2%%hh%%time:~3,2% mins set/a mins-=minsago call:minstodate%mins% dstyear DstMonth DstDay DstHour DstMin > "%ftpdir%" echo.%ftpuser% >> "%ftpdir%" echo.%ftppass% >> "%ftpdir%" Echo bin >> "%ftpdir%" Echo CD " %ftpfolder% ">>"%ftpdir% "Echo dir *"%temp%/filelist2.txt ">>"%ftpdir% "echo Bye start ftp-v-i-s:"%ftpdir% "%ftpip% REM Adjusts the delay time according to the actual situation ping-n 127.1 >nul findstr/i":*/. swm$ ""%temp%/filelist2.txt ">"%temp%/filedate2.txt "findstr/i":*/. twm$ ""%temp%/filelist2.txt ">>"%temp%/filedate2.txt "findstr/i":*/. owm$ "%temp%/filelist2.txt" >> "%temp%/filedate2.txt" > "%ftpdown%" echo.%ftpuser% >> "%ftpdown%" echo. %ftppass% >> "%ftpdown%" Echo bin >> "%ftpdown%" Echo CD "%ftpfolder%" (for/f, Usebackq tokens=1-10 delims=: " %%a in ("%temp%/filedate2.txt") does (setlocal enabledelayedexpansion if "%%f" equ "Out of the Box" (set filem=01) Else I F "%%f" Equ "Feb" (set filem=02) else if "%%f" Equ "Mar" (set filem=03) else if "%%f" Equ "APR" (set FILEM=04) Else if "%%f" Equ "may" (set filem=05) else if "%%f" Equ "June" (set filem=06) else if "%%f" E
  Qu "June" (set filem=07) else if "%%f" Equ "Aug" (set filem=08) else if "%%f" Equ "Sep" (Set filem=09 else if "%%f" Equ "Oct" (set filem=10) else if "%%f" Equ "Nov" (set filem=11) else if "%%f" equ "Dec" (set filem=12) set filed=10%%g set filed=!
  filed:~-2!
 Set Fileh=10%%h Set fileh=!
  fileh:~-2! If "! filem! "Equ"%dstmonth% "(if"!) filed! "Equ"%dstday% "(if"!) fileh! "Equ"%dsthour% "(Echo Get"%%j ""%downfolder%/%%j ")) endlocal)) >>"%ftpdown% ">>"%ft " pdown% "echo Bye start ftp-v-i-s:"%ftpdown% "%ftpip% rem Adjust the delay time according to the actual situation rem Ping-n-127.1 >nul-goto:eof:D at Etomins%yy%%mm%%dd%%hh%%mm% setlocal enableextensions set yy=%1&set mm=%2&set dd=%3&set hh=%4&set nn= %5 if 1%yy% LSS/if 1%yy% LSS 170 (set yy=20%yy%) Else (set yy=19%yy%) set/a dd=100%dd%%%100,mm=100%mm%%%100 set/a z= 14-mm,z/=12,y=yy+4800-z,m=mm+12*z-3,j=153*m+2 set/a j=j/5+dd+y*365+y/4-y/100+y/400-2472633 If 1%hh% LSS set hh=0%hh % if {%nn:~2,1%} EQU {p} if "%hh%" NEQ "set hh=1%hh%&set/a hh-=88 if {%nn:~2,1%} EQU {A} if"%hh% "EQU" "Set hh =00 if {%nn:~2,1%} GEQ {A} set nn=%nn:~0,2% set/a hh=100%hh%%%100,nn=100%nn%%%100,j=j*1440+hh*60+nn endlocal&set %j%&goto:eof:minstodate%mins% yy mm dd hh nn setlocal enableextensions set/a i=%1,nn=i%%60,i/=60,hh=i%%24,dd=i/24,i/=24 set/a a=i+2472632,b=4*a+3,b/= 146097,c=-b*146097,c/=4,c+=a set/a d=4*c+3,d/=1461,e=-1461*d,e/=4,e+=c,m=5*e+2,m/=153,dd=153*m+2,dd/=5 set/a dd=-
DD+E+1,MM=-M/10,MM*=12,MM+=M+3,YY=B*100+D-4800+M/10 (if%mm% LSS set mm=0%mm%) & (if%dd% LSS set dd=0%dd%) (If%hh% LSS set hh=0%hh%) & (if%nn% LSS set nn=0%nn%) endlocal&set%6=%nn%&set%5=%hh%&set%4=%DD%&A mp;^ Set%3=%mm%&set%2=%yy%&goto:eof

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.