For your first question, the following code can be used to implement it:
@echo off
:: Please ensure that there are no sensitive characters under CMD in each text file
:: 180 can be modified to the 596 you want
:: To get the function of merging specified files, please modify the following code by yourself
del /a /q /f new001.txt 2>nul
setlocal enabledelayedexpansion
for /l %%i in (1,1,180) do (
set num=%%i
if %%i lss 10 set num=00%%i
if %%i geq 10 if %%i lss 100 set num=0%%i
for /f "delims=" %%j in (!num!.txt) do >>new001.txt echo%%j
)
start new001.txt
Hitme once did the statistics on the frequency of Chinese character occurrence, but it seems that the result is not very accurate. Here is his code for everyone to discuss
Bored, just messing around, test
Function: Count the number of times each word appears in the text
Usage:
Under cmd
word_num file name
Statistical result style:
0152 fixed
0108 added
0094 in
0091 to
0070 will
0069 not
0062 problem
0059 the
0056 bar
0054 support
0054 at
0053 and
0050 for
0047 menu
0046 tab
0042 when
0041 new
0040 option
0040 changed
0038 myie2
0037 plugin
0036 favorite
0035 toolbar
0035 on
Code
@echo off
cls
echo.
echo.-----------------------------
echo....Counting in progress.....Please wait a moment...
echo.-----------------------------
echo.
if "%*" "" goto :syntax
if "%*" "/?" goto :syntax
if "%*" "/" goto :syntax
if "%*" "?" goto :syntax
if /i "%*" "/help" goto :syntax
:: /* Split the text into one word per line */
setlocal ENABLEDELAYEDEXPANSION
del end.txt tmp*.txt 2>nul
set /a m=0
:loop
set /a m+=1
for /f "tokens=%m% delims=.,:;/()!'@=\<> " %%i in (%*) do (
set n=%%i
set n=!n:"=!
echo.1 !n!>>tmp.txt
)
if "%m%" "200" goto:add
goto:loop
endlocal
:add
:: /* Summarize by category */
setlocal ENABLEDELAYEDEXPANSION
for /f "tokens=1,2" %%i in ('sort tmp.txt^|findstr /r "^1\ "') do (
if /i "!y!" "%%j" (
set /a x+=1) else (if "!x!" neq "" (
if !x! lss 10 (echo.000!x! !y!>>tmp1.txt) else (
if !x! lss 100 (echo.00!x! !y!>>tmp1.txt) else (
if !x! lss 1000 (echo.0!x! !y!>>tmp1.txt))))
set y=%%j
set x=%%i)
)
if !x! lss 10 (echo.000!x! !y!>>tmp1.txt) else (
if !x! lss 100 (echo.00!x! !y!>>tmp1.txt) else (
if !x! lss 1000 (echo.0!x! !y!>>tmp1.txt)))
endlocal
sort /r tmp1.txt>tmp2.txt
:ex
:: /* Convert uppercase to lowercase */
setlocal ENABLEDELAYEDEXPANSION
for /f "delims=" %%i in (tmp2.txt) do (
set ex=%%i
set ex=!ex:A=a!
set ex=!ex:B=b!
set ex=!ex:C=c!
set ex=!ex:D=d!
set ex=!ex:E=e!
set ex=!ex:F=f!
set ex=!ex:G=g!
set ex=!ex:H=h!
set ex=!ex:I=i!
set ex=!ex:J=j!
set ex=!ex:K=k!
set ex=!ex:L=l!
set ex=!ex:M=m!
set ex=!ex:N=n!
set ex=!ex:O=o!
set ex=!ex:P=p!
set ex=!ex:Q=q!
set ex=!ex:R=r!
set ex=!ex:S=s!
set ex=!ex:T=t!
set ex=!ex:U=u!
set ex=!ex:V=v!
set ex=!ex:W=w!
set ex=!ex:X=x!
set ex=!ex:Y=y!
set ex=!ex:Z=z!
echo.!ex!>>end.txt
)
del tmp*.txt
start end.txt
:syntax
cls
echo.
echo.word_num.cmd
echo.
echo.written by hitme 2005.9.2
echo.Usage:
echo.word_num file name
echo.
echo.Example:
echo.word_num License.txt
echo.
To count Chinese characters, the usage is the same as the top floor. Try to figure out how to make it vertical in a column
Code:
@echo off
setlocal ENABLEDELAYEDEXPANSION
for /f "delims=" %%i in (%1) do (
set n=%%i
echo.!n!>tmp.txt
echo.x>>tmp.txt
for /f "tokens=1 delims=:" %%a in ('findstr /o "x" tmp.txt') do set lenth=%%a
for /l %%a in (0,1,!lenth!) do (
set m=!n:~%%a,1!
if "!m!" neq "" echo.1 !m!>>tmp1.txt
)
)
:add
for /f "tokens=1,2" %%i in ('sort tmp1.txt') do (
if "!y!" "%%j" (
set /a x+=1) else ( if "!x!" neq "" (
if !x! lss 10 (echo.000!x!
!y!>>tmp2.txt) else (
if !x! lss 100 (echo.00!x!
!y!>>tmp2.txt) else (
if !x! lss 1000 (echo.0!x!
!y!>>tmp2.txt))))
set y=%%j
set x=%%i)
)
if !x! lss 10 (echo.000!x! !y!>>tmp2.txt) else (
if !x! lss 100 (echo.00!x! !y!>>tmp2.txt) else (
if !x! lss 1000 (echo.0!x! !y!>>tmp2.txt)))
endlocal
sort /r tmp2.txt>end.txt
del tmp*.txt
start end.txt
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。