How are batch processing line numbers added?
http://www.cn-dos.net/forum/viewthread.php?tid=21664
[ Last edited by dosz on 2009-4-11 at 10:26 ]
http://www.cn-dos.net/forum/viewthread.php?tid=21664
dosz posted on: 2009-04-11 21:14
- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- :: Batch2ubb.cmd -V0.30 -- Batch to UBB Code
- :: NaiWuHe@cn-dos.net - Updated: 2005-7-30 - CMD & GAWK
- :: Usage: Batch2ubb
- :: Supported files: - gawk.exe winclip.exe Batch2ubb.awk batch.esy
- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- @echo off
- setlocal
- set path=%path%;%cd%;%~dp0
- set error=
- rem File integrity check.
- for %%i in (gawk.exe winclip.exe batch.esy batch2ubb.awk) do (
- @if "%%~$PATH:i" == "" (
- echo Error: Dependent file "%%i" is missing.
- set error=Error: Program files are incomplete.
- ) else ( set %%~ni="%%~$PATH:i" )
- )
- if defined error goto error
- rem Test clipboard data type.
- winclip -i |findstr /r ".*_.*TEXT" >nul
- if ERRORLEVEL 1 set error=Error: Clipboard is empty or contains non-text data!
- rem Empty parameter call to get clipboard data and copy conversion result to clipboard.
- if "%~1" == "" (
- if defined error goto error
- winclip -p |gawk -v line=1 -f %Batch2ubb% |winclip -c
- goto end
- )
- rem When there is only one parameter, try to handle it as an input file, and treat it as a parameter if it does not exist.
- if "%~2" == "" (
- if exist "%~1" (
- gawk -v line=1 -f %Batch2ubb% "%~1" |winclip -c
- goto end
- )
- )
- set line=1
- set input=
- set out=
- :ParseLoop
- if "%~1" == "" goto Start
- if "%~1" == "/?" goto SwitchH
- rem Parameter processing and jump to corresponding label.
- for %%s in (i I n N o O h H) do if "%~1"=="/%%s" goto Switch%%s
- set error=Error: Incorrect parameter format - "%1"!
- goto error
- :SwitchI
- set "input=%~2"
- if not exist "%input%" set error=Warning: File "%input%" does not exist. & goto error
- goto Next2Arg
- :SwitchO
- set "out=%~2"
- if not defined out set error=Warning: Please specify an output file. & goto error
- goto Next2Arg
- :SwitchN
- set line=0
- goto NextArg
- :Next2Arg
- shift
- :NextArg
- shift
- goto ParseLoop
- rem Different parameter classification judgment processing.
- :Start
- if defined input (
- if defined out (
- gawk -v line=%line% -f %Batch2ubb% "%input%" >"%out%"
- ) else (
- gawk -v line=%line% -f %Batch2ubb% "%input%" |winclip -c
- )
- ) else (
- if defined out (
- if defined error goto error
- winclip -p |gawk -v line=%line% -f %Batch2ubb% >"%out%"
- ) else (
- if defined error goto error
- winclip -p |gawk -v line=0 -f %Batch2ubb% |winclip -c
- )
- )
- goto end
- :error
- echo.%error%
- echo.
- :SwitchH
- echo.Batch to UBB Code.
- echo.Batch2ubb
- echo.
- echo. /i Specify the file to be converted, which can include a path, and the default is obtained from the clipboard.
- echo. /o Specify the output file, which can include a path, and the default is output to the clipboard.
- echo. /n Generate UBB code without line numbers, the default is with line numbers.
- echo. /h Display this brief help, equivalent command /?.
- echo. This program depends on the following files gawk.exe winclip.exe Batch2ubb.awk batch.esy.
- echo.
- :end
[ Last edited by dosz on 2009-4-11 at 10:26 ]
*/. . . * .
.\* . * dosz
*/ . ./\~~~~~~~~~~~~'\. ^|◆
\* ,/,..,\,...........,\.◆
^|^| ..▎# ▎田 田 ▎ ^| ▎◆
^|^| ^&^&▎ ▎ ▎'^|'▎ o
^|^| ##■■■■■■■■■■〓
.\* . * dosz
*/ . ./\~~~~~~~~~~~~'\. ^|◆
\* ,/,..,\,...........,\.◆
^|^| ..▎# ▎田 田 ▎ ^| ▎◆
^|^| ^&^&▎ ▎ ▎'^|'▎ o
^|^| ##■■■■■■■■■■〓


