@echo off
set file=D:\Cc.ini
set strFtpPath=
call:readini %file% FtpMsg FtpDir strFtpPath
echo "ftp path dir:" %strFtpPath%
IF "%strFtpPath%"=="" (
echo Get ftp file path fail, Please delete it manually!!!
pause
exit
)
set strFtpPath=%strFtpPath%\Data
echo "BCP dir:" %strFtpPath%
::del /S /Q %strFtpPath%
ren %strFtpPath% "Data_bak"
pause
::exit
:: 读取ini配置. %~1:文件名,%~2:域,%~3:key %~4:返回的value值
:readini
@setlocal enableextensions enabledelayedexpansion
@echo off
set file=%~1
set area=[%~2]
set key=%~3
set currarea=
for /f "usebackq delims=" %%a in ("!file!") do (
set ln=%%a
if "x!ln:~0,1!"=="x[" (
set currarea=!ln!
) else (
for /f "tokens=1,2 delims==" %%b in ("!ln!") do (
set currkey=%%b
set currval=%%c
if "x!area!"=="x!currarea!" (
if "x!key!"=="x!currkey!" (
set var=!currval!
)
)
)
)
)
(endlocal
set "%~4=%var%"
)
goto:eof