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-06-24 14:35
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Original] Batch Processing Online Word Check View 5,160 Replies 21
Original Poster Posted 2007-01-04 00:47 ·  中国 北京 中移铁通
荣誉版主
★★★
Credits 1,338
Posts 356
Joined 2005-07-15 12:09
20-year member
UID 40733
Gender Male
Status Offline
The things written yesterday were forgotten to be posted. It's a simple online word lookup with data from Kingsoft Ciba.

Requires support for wget or curl. If you need the朗读 function, support for mplayer is required.

Usage: dict word ...
/F: Query the word in full mode.
word: Multiple words can be specified.
Supports word朗读 function.

Links to required software:
mplayer: http://www.mplayerhq.hu
wget: http://users.ugent.be/~bpuype/wget/
or curl: http://curl.haxx.se/



  1. :::::::::::::::::::::::::::::::::::::::::::::::::
  2. :: dict.cmd -V0.1 -- Batch online word lookup
  3. :: Nai Wu He@cn-dos.net - 2007-1-2
  4. :: Usage: dict word ...
  5. :: Dependent files: - mplayer.exe wget.exe or curl.exe
  6. :::::::::::::::::::::::::::::::::::::::::::::::::
  7. @echo off
  8. setlocal ENABLEDELAYEDEXPANSION
  9. set mp3file="%TEMP%\dict.mp3"
  10. rem Check dependent files
  11. :mplay
  12. call mplayer >nul 2>nul
  13. if "%ERRORLEVEL%" == "1" set nomplay=1

  14. :wget
  15. wget.exe >nul 2>nul
  16. if not "%ERRORLEVEL%" == "9009" (
  17. set "command1=wget -q -O - "
  18. set "command2=wget -q -O %mp3file%"
  19. goto star
  20. )

  21. :curl
  22. curl.exe >nul 2>nul
  23. if not "%ERRORLEVEL%" == "9009" (
  24. set "command1=curl -s "
  25. set "command2=curl -s -o %mp3file%"
  26. goto star
  27. )
  28. echo.This script requires support for wget or curl.
  29. goto :EOF

  30. :star
  31. set flag=0
  32. if "%~1" == "" goto help
  33. if "%~1" == "?" goto help
  34. if "%~1" == "/?" goto help
  35. if "%~1" == "/F" shift &goto full
  36. if "%~1" == "/f" shift &goto full


  37. :next
  38. if "%~1" == "" goto :EOF
  39. set "word=%~1"
  40. call :down
  41. shift
  42. goto :next

  43. :full
  44. if "%~1" == "" goto :EOF
  45. set mp3=
  46. del %mp3file% 2>nul
  47. set "word=%~1"
  48. call :down
  49. %command2% "%mp3%"
  50. echo.--------------------------------
  51. if "%mp3%" == "" echo. View detailed explanation Exit &goto :Nselect
  52. echo. Read aloud View detailed explanation Exit
  53. :Nselect
  54. set select=
  55. set /p select=Please select:
  56. call :Parse
  57. if "%quit%" == "1" goto :EOF
  58. shift
  59. goto :full


  60. :Parse
  61. for %%s in (R r F f A a) do if "%%s" == "%select%" goto Switch%select%
  62. goto :EOF

  63. :SwitchR
  64. if "%nomplay%" == "1" echo. Playing audio requires support for mplayer. &goto :Nselect
  65. start /min %ComSpec% /c "mplayer %mp3file%>nul"
  66. goto :Nselect
  67. goto :EOF

  68. :SwitchF
  69. start http://www.iciba.com/search?s=%word%
  70. goto :Nselect
  71. goto :EOF

  72. :SwitchA
  73. set quit=1
  74. goto :EOF


  75. :down
  76. set url="http://dict.cn/ws.php?q=%word%"
  77. echo.
  78. echo.Word: %word%
  79. echo.Explanation:
  80. for /f "tokens=1,2,3 delims=<>" %%a in ('%command1% %url%') do (
  81. if "%%a" == "audio" set "mp3=%%b"
  82. if "%%b" == "Not Found" echo No such word^^! &goto :EOF
  83. if "%%c" == "/def" echo %%b &goto :EOF
  84. if "%%b" == "/def" echo %%a &set flag=0
  85. if "!flag!" == "1" echo %%a
  86. if "%%a" == "def" echo %%b &set flag=1
  87. )
  88. goto :EOF

  89. :help
  90. echo.Batch online word lookup
  91. echo.
  92. echo.Usage: dict word ...
  93. echo.
  94. echo /F Query the word in full mode.
  95. echo word Multiple words can be specified.
  96. goto :EOF
Nai Wu He posted on 2007-01-03 12:11


[ Last edited by Nai Wu He on 2007-1-4 at 01:16 AM ]
Recent Ratings for This Post ( 6 in total) Click for details
RaterScoreTime
ccwan +15 2007-01-04 01:25
redtek +11 2007-01-04 03:14
lxmxn +8 2007-01-04 05:55
huzixuan +4 2007-03-17 06:30
0401 +4 2007-03-17 09:26
chengbiner +1 2007-03-17 11:24
  ☆开始\运行 (WIN+R)☆
%ComSpec% /cset,=何奈无── 。何奈可无是原,事奈无做人奈无&for,/l,%i,in,(22,-1,0)do,@call,set/p= %,:~%i,1%<nul&ping/n 1 127.1>nul

Floor 2 Posted 2007-01-04 01:26 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 3 Posted 2007-01-04 03:15 ·  中国 北京 朝阳区 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
Appreciate~~
The content is becoming more comprehensive and more attractive~~ :)))
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 4 Posted 2007-01-04 03:55 ·  中国 广东 肇庆 电信
初级用户
★★
Credits 152
Posts 74
Joined 2005-12-01 23:06
20-year member
UID 46314
Status Offline
One word=====Strong!
Floor 5 Posted 2007-01-04 04:29 ·  中国 浙江 宁波 电信
初级用户
Credits 38
Posts 19
Joined 2006-10-22 23:11
19-year member
UID 67763
Gender Male
Status Offline
I can't use it, ashamed
Floor 6 Posted 2007-01-04 05:35 ·  中国 广东 广州 白云区 电信
初级用户
★★
Credits 172
Posts 54
Joined 2007-01-02 10:38
19-year member
UID 75260
Gender Male
Status Offline
It doesn't work. After double-clicking, it flashes and then exits. I have already downloaded wget and stored it in WINDOWS, and I also tried storing it in system32. The result is still the same.
Floor 7 Posted 2007-01-04 05:47 ·  中国 河北 廊坊 三河市 移动
金牌会员
★★★★
Credits 2,725
Posts 1,160
Joined 2006-09-23 12:00
19-year member
UID 63486
From 河北廊坊
Status Offline
Sent by mistake, sigh! =_=|||

[ Last edited by ccwan on 2007-1-4 at 05:55 AM ]
三人行,必有吾师焉。 学然后知不足,教然后知困,然后能自强也。
Floor 8 Posted 2007-01-04 05:53 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
  Without the word library of Kingsoft, can some friends send one up?
Floor 9 Posted 2007-01-04 06:25 ·  中国 甘肃 兰州 七里河区 电信_甘肃龙源风力发电有限公司
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
Hehe, I did it simply before, didn't perfect it. Admire the moderator. If it were up to me, it would be wget + sed
Floor 10 Posted 2007-01-04 06:29 ·  中国 甘肃 兰州 七里河区 电信_甘肃龙源风力发电有限公司
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
Is the sound file a .swf?
Floor 11 Posted 2007-01-04 07:19 ·  中国 北京 中移铁通
荣誉版主
★★★
Credits 1,338
Posts 356
Joined 2005-07-15 12:09
20-year member
UID 40733
Gender Male
Status Offline
RE dosmania
Why double-click to run? Then you can only see the help and it flashes by. Call it in the command line.

RE lxmxn
No need for a thesaurus, look up online. Are you talking about the dictionary of Kingsoft PowerWord?

RE vkill
The sound is in mp3 format. http://www.iciba.com/ is swf format.
  ☆开始\运行 (WIN+R)☆
%ComSpec% /cset,=何奈无── 。何奈可无是原,事奈无做人奈无&for,/l,%i,in,(22,-1,0)do,@call,set/p= %,:~%i,1%<nul&ping/n 1 127.1>nul

Floor 12 Posted 2007-01-06 02:15 ·  中国 甘肃 甘南藏族自治州 合作市 电信
金牌会员
★★★★
Credits 4,103
Posts 1,744
Joined 2006-01-20 13:00
20-year member
UID 49241
Gender Male
From 甘肃.临泽
Status Offline
RE 无奈何 Moderator
I think using mplayer to play from iciba is better, heh heh, simple

@echo off
:start
set search=
set /p search=Please enter the word to translate:
set search_x=%search:~0,1%
echo %search% pronunciation:
mplayer http://www.iciba.com/resource/a/en/%search_x%/%search%.swf>nul
goto start
Floor 13 Posted 2007-01-07 02:37 ·  中国 山东 济南 电信
初级用户
Credits 97
Posts 30
Joined 2006-12-30 10:54
19-year member
UID 75006
Gender Male
Status Offline
It's getting more and more interesting. It seems I need to study hard.
Floor 14 Posted 2007-03-16 08:00 ·  中国 湖北 武汉 江夏区 电信
初级用户
Credits 76
Posts 38
Joined 2007-03-13 02:54
19-year member
UID 81544
Gender Male
Status Offline
Good stuff
Floor 15 Posted 2007-03-17 05:52 ·  中国 安徽 马鞍山 电信
中级用户
★★
Credits 493
Posts 228
Joined 2007-02-16 00:38
19-year member
UID 79596
Gender Male
From 安徽
Status Offline
Forum Jump: