Get the App
SLTechnology News&Howtos  ›  Development  › 

How to download files before a specified number of days on a FTP server by batch bat

Shulou Source: shulou.com Published: 2022-06-03 08:25:11 11月15日 Update

This article mainly introduces the batch processing bat how to download the files before the specified number of days on the FTP server, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand it.

Sample code:

@ echo offrem specify FTP username set ftpUser=asxrem specify FTP password set ftpPass=asx-asxrem specify FTP server address set ftpIP=172.19.103.7rem specify where the file to be downloaded is located on the FTP server set ftpFolder=/export/home/PROD/ntcdatarem specify where the file downloaded from FTP is stored set LocalFolder=E:/Temprem specify the file downloaded a few days ago set DaysAgo=1set ftpDir=%temp%/TempDir.txtset ftpDown=%temp%/TempDown.txtrem assume this machine Date format is yyyy-mm-ddset FileY=%date:~0,4%call: DateToDays% date:~0,4%% date:~5,2%% date:~8,2% PassDaysset / a PassDays-=DaysAgocall: DaysToDate% PassDays% DstYear DstMonth DstDay >% ftpDir% "echo FtpUser% > > 'ftpDir%' echo % ftpPass% > > "% ftpDir%" echo bin > > "% ftpDir%" echo cd "% ftpFolder%" > > "% ftpDir%" echo dir * "% temp%/FileList.txt" > > "% ftpDir%" echo byestart ftp-v-I-s: "% ftpDir%"% ftpIP%rem adjusts the delay time ping-n 200 200 > nulfindstr / I ": * / .SWM $"% temp%/FileList.txt" > "% temp%/FileDate.txt" findstr according to the actual situation / I ": * / .TWM $"% temp%/FileList.txt" > > "% temp%/FileDate.txt" findstr / I ": * / .OWM $"% temp%/FileList.txt" > > "% temp%/FileDate.txt" > "% ftpDown%" echo.%ftpUser% > > "% ftpDown%" echo.%ftpPass% > > "% ftpDown%" echo bin > > "% ftpDown%" echo cd "% ftpFolder%" (for / f "usebackq tokens=1-9 delims="% an in ") Temp%/FileDate.txt ") do (setlocal enabledelayedexpansion if"% f "equ" Jan "(set FileM=01) else if"% 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" Jun "( Set FileM=06) else if "% f" equ "Jul" (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 FileDrubs, FileDrubs, etc. If "! FileM!" Equ "% DstMonth%" (if "! FileD!" Equ "% DstDay%" (echo get "% I"% LocalFolder%/%%i") endlocal) > > "% ftpDown%" > > "% ftpDown%" echo byestart ftp-v-I-s: "% ftpDown%"% ftpIP%goto: eof:DateToDays% yy%% mm%% dd% dayssetlocal ENABLEEXTENSIONSset yy=%1&set mm=%2&set dd=%3if 1% y% LSS 200 if 1% y% LSS 170 (set yy=20%yy%) else ( Set yy=19%yy%) set / a dd=100%dd%%0 Mm=100%mm%%0set / a zipper 1400 MMJ 4800 MMQ 12MMJ 3MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMYO3GOOG: EOF:DaysToDate% days% yy mm ddsetlocal ENABLEEXTENSIONSset / an aquired% 1' 2472632 4=%j%&goto: EOF:DaysToDate% days% yy mm ddsetlocal ENABLEEXTENSIONSset / an axiom% 1' 2472632 4=%j%&goto: EOF:DaysToDate% days% yy mm ddsetlocal ENABLEEXTENSIONSset / an axiom% 1' 2472632 4=%j%&goto: EOF:DaysToDate% days% yy mm ddsetlocal ENABLEEXTENSIONSset / an axiom% 1' 2472632 camera blister 146097 lead to 4parente caster 146097repertoire, 1461paramente aset / a dandelike 3linger, 1461theatrical, 461theatrical, 461cm, 51m, 51m, 51m, 51m, 153m, 153cm. Dd/=5set / a dd=-dd+e+1,mm=-m/10,mm*=12,mm+=m+3,yy=b*100+d-4800+m/10 (if% mm% LSS 10 set mm=0%mm%) & (if% dd% LSS 10 set dd=0%dd%) endlocal&set% 2=%yy%&set% 3=%mm%&set% 4=%dd%&goto: EOF Thank you for reading this article carefully I hope the article "how to download files before a specified number of days on a FTP server by batch bat" shared by the editor is helpful to everyone. At the same time, I also hope that you can support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: File server service article days code value location interest at the same time address place actual password situation date time more friends format Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Apple OPPO Reno Xiaomi Huawei