最近用批处理写了一个背单词的小程序。
使用说明:
1.将单词保存到TXT文件中,并放入WordData文件夹。
格式:单词+两个空格+释义
例:abandon vt.丢弃;放弃,抛弃
每行一个,回车换行。
2.打开WordShow.BAT,输入TXT文件名,不含后缀。
3.功能键:
Enter —— 切换单词
Q+Enter —— 保存当前单词到 [ TXT文件名_UF.txt ]
W+Enter —— 查询当前单词
源码:
@echo off & mode con: cols=50 lines=3 & setlocal enabledelayedexpansion
:: Code by: 渤海琴师 QQ: 970097556
:: CMD@Windows10 2020-06-21
:: bohaiqinshi.com
title WordShow — bohaiqinshi.com
color F0
:rp1
echo.
set /p FileName=
cls
if not exist "WordData\%FileName%.txt" goto rp1
set num_new=0
for /f "delims=""" %%i in (WordData\%FileName%.txt) do (
set /a num_new+=1
)
set num_total=%num_new%
if not exist "WordData\%FileName%.dat" (cd.>"WordData\%FileName%.dat")
:rp2
set /p num_old=<"WordData\%FileName%.dat"
set num_new=0
for /f "delims=""" %%i in (WordData\%FileName%.txt) do (
set /a num_new+=1
echo !num_new!>"WordData\%FileName%.dat"
if !num_new! geq !num_old! (
title !num_new!/%num_total%
echo.
echo %%i
set choice=""
set /p choice=
if /I "!choice!"=="q" (
if not exist "WordData\%FileName%_uf.txt" (cd.>"WordData\%FileName%_uf.txt")
set flag=0
for /f "delims=""" %%j in (WordData\%FileName%_uf.txt) do (
if %%i==%%j set flag=1
)
if !flag! equ 0 echo %%i>>"WordData\%FileName%_uf.txt"
)
if /I "!choice!"=="w" (
for /f "tokens=1* delims= " %%a in ("%%i") do (
start "" "http://dict.youdao.com/w/eng/%%a"
)
cls&goto rp2
)
cls
)
)
cd.>"WordData\%FileName%.dat"
set num_old=
goto rp2
下载地址:WordShow.zip