如何使用bat制作字典

问题描述 投票:0回答:2
我有一个给定的文件。我需要创建一个包含 27 个文件的文件夹。第一个文件包含给定文件中按字母顺序排列的唯一单词,以 a 开头,第二个文件以 b 开头,依此类推。

第27个文件包含以其他字符开头的单词。我设法使用

awk

 来完成我的字典,但我必须用 
bat
 来完成,这给我带来了很多问题。

batch-file
2个回答
3
投票
请注意,您没有要求我们

解释批处理文件,对吗? :-)

@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
    

-1
投票
有很多不同的方法可以做到这一点,但我会推荐这样的方法:

@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
    
© www.soinside.com 2019 - 2024. All rights reserved.