0

一个bat的流程范例

| |
2006/12/05    14:40    1099    GreyHawk 晴
@echo off

setlocal ENABLEDELAYEDEXPANSION

if "%1"=="" goto error1
if "%2"=="" goto error1

if exist %2 del %2

if "%3"=="debug" (set _debug_=1) else (set _debug_=0)
set _state_=0
set _label_=
set _site_=
set _port_=
set _username_=
set _password_=

for /f "tokens=*" %%a in (%1) do (
   if !_state_!==0 (
       for /f "tokens=1,2,3,4 delims=.:" %%i in ("%%a") do (
             if "%%j"=="et8" if "%%k"=="net" (
                 set _label_=%%i
                 set _site_=%%i.%%j.%%k
                 if "%%l"=="" (set _port_=21) else (set _port_=%%l)
                 set _state_=1
                 if %_debug_%==1 echo [debug] site/port: !_site_!/!_port_!
             )

       )
   ) else if !_state_!==1 (
       for /f "tokens=1,2 delims= " %%i in ("%%a") do (
             if not "%%i"=="用户名:" goto error2
             set _username_=%%j
             set _state_=2
             if %_debug_%==1 echo [debug] username: !_username_!
       )
   ) else if !_state_!==2 (
       for /f "tokens=1,2 delims= " %%i in ("%%a") do (
             if not "%%i"=="密 码:" goto error2
             set _password_=%%j
             set _state_=0
             if %_debug_%==1 echo [debug] echo password: !_password_!

             rem type1: echo ftp://!_username_!:!_password_!@!_site_!:!_port_!>> %2

             echo Site Label: !_label_!>> %2
             echo HostName: !_site_!>> %2
             echo User Name: !_username_!>> %2
             echo Password: !_password_!>> %2
             echo Port: !_port_!>> %2
             echo.>> %2
       )
   )
)

echo output file generated successfully. check %2
goto end

:error1
echo usage:
echo.
echo 1. open the ftp list page from forum
echo 2. copy all text (ctrl+a, ctrl+c)
echo 3. open notepad, paste text into it and save as a text file, i.e., list.txt
echo 4. run this script from command line:
echo   genffxp list.txt out.txt
echo 5. import out.txt into flashfxp sites, using format "text file type 2"
echo   (it is strongly recommended that you create a group before importing)
echo.
echo ssl information must be set manually at this point.

goto end

:error2
echo failed to parse the text
goto end

:end
set _state_=
set _site_=
set _username_=
set _password_=
set _label_=
set _site_=
set _port_=
set _username_=
set _password_=
set _debug_=

收藏本文到网摘: 添加到“Google书签” 添加到“Yahoo收藏” 添加到“QQ书签” 添加到“百度搜藏” 添加到“新浪ViVi收藏夹” 添加到“Del.icio.us” 添加到“365天天网摘” 添加到“天极网摘” 添加到“POCO网摘” 添加到“和讯网摘” 添加到“Bolaa博客收录中心” 添加到“igooi网摘” 添加到“天下图摘”
Tags: | 分类:操作技巧 » 日常应用 | 来源:本站原创 | 引用(0)