China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-11 17:40
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Discussion] How are batch processing line numbers added? View 1,726 Replies 6
Original Poster Posted 2009-04-11 10:20 ·  中国 上海 浦东新区 电信
中级用户
★★
一看二跟三动手
Credits 396
Posts 188
Joined 2005-10-23 13:21
20-year member
UID 43919
From 上海
Status Offline
How are batch processing line numbers added?
http://www.cn-dos.net/forum/viewthread.php?tid=21664


  1. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

  2. :: Batch2ubb.cmd -V0.30 -- Batch to UBB Code

  3. :: NaiWuHe@cn-dos.net - Updated: 2005-7-30 - CMD & GAWK

  4. :: Usage: Batch2ubb

  5. :: Supported files: - gawk.exe winclip.exe Batch2ubb.awk batch.esy

  6. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::



  7. @echo off

  8. setlocal

  9. set path=%path%;%cd%;%~dp0

  10. set error=

  11. rem File integrity check.

  12. for %%i in (gawk.exe winclip.exe batch.esy batch2ubb.awk) do (

  13. @if "%%~$PATH:i" == "" (

  14. echo Error: Dependent file "%%i" is missing.

  15. set error=Error: Program files are incomplete.

  16. ) else ( set %%~ni="%%~$PATH:i" )

  17. )

  18. if defined error goto error



  19. rem Test clipboard data type.

  20. winclip -i |findstr /r ".*_.*TEXT" >nul

  21. if ERRORLEVEL 1 set error=Error: Clipboard is empty or contains non-text data!



  22. rem Empty parameter call to get clipboard data and copy conversion result to clipboard.

  23. if "%~1" == "" (

  24. if defined error goto error

  25. winclip -p |gawk -v line=1 -f %Batch2ubb% |winclip -c

  26. goto end

  27. )

  28. 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.

  29. if "%~2" == "" (

  30. if exist "%~1" (

  31. gawk -v line=1 -f %Batch2ubb% "%~1" |winclip -c

  32. goto end

  33. )

  34. )

  35. set line=1

  36. set input=

  37. set out=



  38. :ParseLoop

  39. if "%~1" == "" goto Start

  40. if "%~1" == "/?" goto SwitchH

  41. rem Parameter processing and jump to corresponding label.

  42. for %%s in (i I n N o O h H) do if "%~1"=="/%%s" goto Switch%%s

  43. set error=Error: Incorrect parameter format - "%1"!

  44. goto error



  45. :SwitchI

  46. set "input=%~2"

  47. if not exist "%input%" set error=Warning: File "%input%" does not exist. & goto error

  48. goto Next2Arg



  49. :SwitchO

  50. set "out=%~2"

  51. if not defined out set error=Warning: Please specify an output file. & goto error

  52. goto Next2Arg



  53. :SwitchN

  54. set line=0

  55. goto NextArg



  56. :Next2Arg

  57. shift

  58. :NextArg

  59. shift

  60. goto ParseLoop



  61. rem Different parameter classification judgment processing.

  62. :Start

  63. if defined input (

  64. if defined out (

  65. gawk -v line=%line% -f %Batch2ubb% "%input%" >"%out%"

  66. ) else (

  67. gawk -v line=%line% -f %Batch2ubb% "%input%" |winclip -c

  68. )

  69. ) else (

  70. if defined out (

  71. if defined error goto error

  72. winclip -p |gawk -v line=%line% -f %Batch2ubb% >"%out%"

  73. ) else (

  74. if defined error goto error

  75. winclip -p |gawk -v line=0 -f %Batch2ubb% |winclip -c

  76. )

  77. )

  78. goto end



  79. :error

  80. echo.%error%

  81. echo.

  82. :SwitchH

  83. echo.Batch to UBB Code.

  84. echo.Batch2ubb

  85. echo.

  86. echo. /i Specify the file to be converted, which can include a path, and the default is obtained from the clipboard.

  87. echo. /o Specify the output file, which can include a path, and the default is output to the clipboard.

  88. echo. /n Generate UBB code without line numbers, the default is with line numbers.

  89. echo. /h Display this brief help, equivalent command /?.

  90. echo. This program depends on the following files gawk.exe winclip.exe Batch2ubb.awk batch.esy.

  91. echo.

  92. :end

dosz posted on: 2009-04-11 21:14


[ Last edited by dosz on 2009-4-11 at 10:26 ]
*/. . . * .
.\* . * dosz
*/ . ./\~~~~~~~~~~~~'\. ^|◆
\* ,/,..,\,...........,\.◆
^|^| ..▎# ▎田 田 ▎ ^| ▎◆
^|^| ^&^&▎ ▎ ▎'^|'▎ o
^|^| ##■■■■■■■■■■〓
Floor 2 Posted 2009-04-11 10:24 ·  中国 上海 浦东新区 电信
中级用户
★★
一看二跟三动手
Credits 396
Posts 188
Joined 2005-10-23 13:21
20-year member
UID 43919
From 上海
Status Offline
Please enter the file name to be searched


  1. @echo off
  2. cls
  3. :loop
  4. set filename=
  5. set/p filename=Please enter the file name to be searched (supports wildcards, such as "*.mp3 mp3.*"):
  6. if not defined filename (cls & if errorlevel 1 cls&msg * dosz Prompt: An incorrect command was entered, why is this~, do you want to fool? &goto loop)
  7. echo.
  8. set/p sheet=Please enter the file name to be written to the list: ┗┛Optional (do not expand the name)
  9. set num=
  10. ECHO ☆☆☆ %DATE% %time% ☆☆☆>%temp%\%sheet%.txt
  11. set drv= C D E F G H I J K L M N O P Q R S T U V W X Y Z
  12. for %%a in (%drv%) do (
  13. if exist %%a:\nul (
  14. cls&echo Searching for %%a: under the disk %filename% ...
  15. dir>nul 2>nul /s/b/a/o "%%a:\%filename%" >>%temp%\%sheet%.txt&&set num=1
  16. )
  17. )
  18. if "%num%" == "1" (
  19. @mode con cols=120
  20. cls&echo.&echo.
  21. color 1f
  22. echo =========== The following files are found for you: "%filename%" and saved to the "%temp%\%sheet%.txt" file ================
  23. title Quick Open File
  24. echo.
  25. for /f "delims=" %%i in (%temp%\%sheet%.txt) do echo %%i
  26. ) else (cls&echo.&echo.&echo ***** No file found: "%filename%" *****&pause>nul&GOTO :EOF)
  27. start %temp%\%sheet%.txt
  28. pause
dosz posted on: 2009-04-11 21:18


[ Last edited by dosz on 2009-4-11 at 10:27 ]
*/. . . * .
.\* . * dosz
*/ . ./\~~~~~~~~~~~~'\. ^|◆
\* ,/,..,\,...........,\.◆
^|^| ..▎# ▎田 田 ▎ ^| ▎◆
^|^| ^&^&▎ ▎ ▎'^|'▎ o
^|^| ##■■■■■■■■■■〓
Floor 3 Posted 2009-04-11 10:35 ·  中国 上海 浦东新区 电信
中级用户
★★
一看二跟三动手
Credits 396
Posts 188
Joined 2005-10-23 13:21
20-year member
UID 43919
From 上海
Status Offline
What I want to talk about is how to solve the problem that line numbers cannot be displayed in the Deepin forum?
http://os.deepin.org/read.php?tid=1052540&page=1&toread=1
*/. . . * .
.\* . * dosz
*/ . ./\~~~~~~~~~~~~'\. ^|◆
\* ,/,..,\,...........,\.◆
^|^| ..▎# ▎田 田 ▎ ^| ▎◆
^|^| ^&^&▎ ▎ ▎'^|'▎ o
^|^| ##■■■■■■■■■■〓
Floor 4 Posted 2009-04-11 10:40 ·  中国 北京 联通
银牌会员
★★★★
[b]看你妹啊[/b]
Credits 1,488
Posts 1,357
Joined 2006-05-20 12:00
20-year member
UID 55770
Status Offline
It seems that this is using the PHPWIND forum deeply, and it may not support UBB.

有问题请发论坛或者自行搜索,再短消息问我的统统是SB
Floor 5 Posted 2009-04-11 12:07 ·  中国 重庆 电信
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Line numbers need to use the tag list
You can go to ShenDu and ask their administrators why they don't support list
Floor 6 Posted 2009-04-11 13:50 ·  中国 广东 东莞 电信
银牌会员
★★★
批处理编程迷
Credits 1,916
Posts 752
Joined 2008-12-28 04:30
17-year member
UID 135147
Gender Male
From 广西
Status Offline


    I've learned it, thank you everyone
    It turns out to be like this



    1. I've learned it, thank you everyone
    2. It turns out to be like this


gg

[ Last edited by netbenton on 2009-4-11 at 18:41 ]
精简
=> 个人网志
Floor 7 Posted 2009-04-11 14:36 ·  中国 北京 联通
银牌会员
★★★★
[b]看你妹啊[/b]
Credits 1,488
Posts 1,357
Joined 2006-05-20 12:00
20-year member
UID 55770
Status Offline
BS upstairs for spamming pure content

有问题请发论坛或者自行搜索,再短消息问我的统统是SB
Forum Jump: