網頁

2023年3月9日 星期四

lftp command

set FTP_USER=digichance
set FTP_PASSWD=sh22463458
set FTP_SITE=114.33.245.149
set FTP_PORT=22
rem set FTP_PORT=7010
set FTP_LOCAL=/cygdrive/D/Photo
set FTP_REMOTE=/d:/temp
set FTP_CMD=lftp.exe
set PATH=%PATH%;C:\lftp-4.9.2.win64-openssl\bin
set PUT=Y
set REMOVE_SOURCE=N

set today=%date:~0,10%
set dy=%today:~0,4%
set dm=%today:~5,2%
set dd=%today:~8,2%
set YES_DAY=%dy%%dm%%dd%
call YesDay.bat %YES_DAY%
echo %YES_DAY%
call YesDay.bat %YES_DAY%
echo %YES_DAY%

if "%REMOVE_SOURCE%"=="Y" (
    set REMOVE_CMD=--Remove-source-dirs
) else (
    set REMOVE_CMD=
)
if "%PUT%"=="Y" (
    set FILE_LIST=-R %FTP_LOCAL%/%1 %1
) else (
    set FILE_LIST=%1 %FTP_LOCAL%/%1
)
%FTP_CMD% -c "set sftp:auto-confirm yes;set net:timeout 5;set net:max-retries 3; open -u %FTP_USER%,%FTP_PASSWD% -p %FTP_PORT% sftp://%FTP_SITE%; cd %FTP_REMOTE%; mirror %REMOVE_CMD% %FILE_LIST%; quit"

rem GET YESTERDAY DATE
rem for Windows 2000,XP,2003
rem http://hi.baidu.com/uroot
@echo off

set dt=%1%
rem date format is "YYYYMMDD"

rem set /P dt="Input Date: "

set dy=%dt:~0,4%
set dm=%dt:~4,2%
set dd=%dt:~6,2%

echo %dy%-%dm%-%dd%
if %dm%%dd%==0101 goto L01
if %dm%%dd%==0201 goto L02
if %dm%%dd%==0301 goto L07
if %dm%%dd%==0401 goto L02
if %dm%%dd%==0501 goto L04
if %dm%%dd%==0601 goto L02
if %dm%%dd%==0701 goto L04
if %dm%%dd%==0801 goto L02
if %dm%%dd%==0901 goto L02
if %dm%%dd%==1001 goto L05
if %dm%%dd%==1101 goto L03
if %dm%%dd%==1201 goto L06

if %dd%==02 goto L10
if %dd%==03 goto L10
if %dd%==04 goto L10
if %dd%==05 goto L10
if %dd%==06 goto L10
if %dd%==07 goto L10
if %dd%==08 goto L10
if %dd%==09 goto L10
if %dd%==10 goto L11
set /A dd=dd-1
set dt=%dy%-%dm%-%dd%
goto END
:L10
set /A dd=%dd:~1,1%-1
set dt=%dy%-%dm%-0%dd%
set dd=0%dd%
goto END
:L11
set dt=%dy%-%dm%-09
set dd=09  
goto END

:L02
set /A dm=%dm:~1,1%-1
set dt=%dy%-0%dm%-31
set dm=0%dm%
set dd=31
goto END
:L04
set /A dm=dm-1
set dt=%dy%-0%dm%-30
set dm=0%dm%
set dd=30
goto END

:L05
set dt=%dy%-09-30
set dm=09
set dd=30
goto END
:L03
set dt=%dy%-10-31
set dm=10
set dd=31
goto END
:L06
set dt=%dy%-11-30
set dm=11
set dd=30
goto END
:L01
set /A dy=dy-1
set dt=%dy%-12-31
set dm=12
set dd=31
goto END

:L07
set /A "dd=dy%%4"
if not %dd%==0 goto L08
set /A "dd=dy%%100"
if not %dd%==0 goto L09
set /A "dd=dy%%400"
if %dd%==0 goto L09
:L08
set dt=%dy%-02-28
set dm=02
set dd=28
goto END
:L09
set dt=%dy%-02-29
set dm=02
set dd=29
goto END

:END
rem echo %dt%
set YES_DAY=%dy%%dm%%dd%

沒有留言:

張貼留言