创建使用批处理单词列表

创建使用批处理单词列表

本文介绍了创建使用批处理单词列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使打印出到一个文本文件中的数字和字母组合列表的批处理文件。结果
使用{ 0 ... 9 A ,...,以Z A ,...,以Z }因为我的性格池,我有62个不同的字符。结果
字长开始为1,并增加多达predetermined值。结果

I want to make a batch file that prints out to a text file a list of combination of numbers and letters.
Using {0, ..., 9, a, ..., z, A, ..., Z} as my character pool, I have 62 unique characters.
The word length starts as 1 and increases up to a predetermined value.

该脚本在开始长度= 1 ,并打印出 0 以Z 。结果
然后它前进到长度= 2 ,并打印出 00 ZZ ,等等...

The script starts at length = 1 and prints out 0 to Z.
Then it proceeds to length = 2 and prints out 00 to ZZ, and so on...

推荐答案

也许这就是你想要什么?

Perhaps this is what you want?

TEST.BAT

@echo off
set charPool=_0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
set charLen=62
(for /L %%a in (1,1,%1) do (
   set permutation=
   call :makePermutation %%a
)) > textfile.txt
goto :EOF

:makePermutation level
setlocal EnableDelayedExpansion
set lastPermutation=%permutation%
for /L %%i in (1,1,%charLen%) do (
   set permutation=!lastPermutation!!charPool:~%%i,1!
   if %1 gtr 1 (
      set /A newLevel=%1-1
      call :makePermutation !newLevel!
   ) else (
      echo(!permutation!
   )
)
exit /B

该批处理文件必须开始与一些为参数是单位长度。

The batch file must be started with a number as parameter which is the unit length.

例如使用 TEST.BAT 1 文本文件 TextFile.txt的包含62行。

For example on using TEST.BAT 1 the text file textfile.txt contains 62 lines.

注意 TEST.BAT 2 生成3906组合(严格地说,的排列的统计意义上的)从0到ZZ和 TEST.BAT 3 生成从0 242234组合ZZZ!

Note that TEST.BAT 2 generates 3906 combinations (strictly speaking, permutations in statistical sense) from 0 to ZZ, and TEST.BAT 3 generates 242234 combinations from 0 to ZZZ!

用于估计在文本文件字符串数(文件大小)的计算示例:

Calculation example for estimating the number of strings in text file (size of file):

运行 TEST.BAT 5 作为参数产生

62 ^ 5 + 62 ^ 4 + 62 ^ 3 + 62 ^ 2 + 62 ^ 1 = 931.151.402

在文本文件中的字符串。

strings in text file.

这篇关于创建使用批处理单词列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 08:44