1

我有一个给定的文件。我需要创建一个包含 27 个文件的文件夹。第一个文件包含给定文件中以 a 开头的按字母顺序排列的唯一单词,第二个文件以 b 开头,依此类推。

第 27 个文件包含以其他字符开头的单词。我设法用 做我的字典awk,但我必须这样做,bat这给我带来了很多问题。

4

2 回答 2

2

请注意,您没有要求我们解释批处理文件,对吧?:-)

@echo off
md folder
for /F "delims=" %%a in (theFile.txt) do (
   for %%b in (%%a) do (
      set word[%%b]=1
   )
)
for %%a in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
   (for /F "tokens=2 delims=[]" %%b in ('set word[%%a') do (
       echo %%b
       set word[%%b]=
   )) > folder\%%a.txt 2>NUL
)
(for /F "tokens=2 delims=[]" %%b in ('set word[') do (
   echo %%b
   set word[%%b]=
)) > folder\other.txt
于 2012-05-03T20:31:55.443 回答
0

从技术上讲,我可以想到许多不同的方法可以做到这一点,但我建议你这样做:

@echo off
title dictionary
color 0a

echo enter the word you want for its definition.
echo.
set/p A=
if %A%==game GOTO game
ELSE
goto end
:end
Exit

:game
cls
echo.
echo game:a competitive activity involving skill, chance, or endurance on the part of two or more 
echo persons who play according to a set of rules, usually for their own amusement or for that of echo spectators.
echo.
pause
:end
Exit

我只是说这个建议来自一个青少年!

于 2014-07-14T04:19:26.357 回答