所以感谢这个伟大网站的一些帮助,我能够生成我想要的特定代码,但现在我试图命名生成的代码和/或将其保存到txt文件。我玩过目的地没有运气。我确信它缺少一些简单的东西。提前致谢。看起来这里的人们非常关注这里的球。我的最后一个问题在不到30分钟内得到了答复:)
@echo off
setlocal enableextensions enabledelayedexpansion
rem Define alphabet
set "alphabet=a b c d f g h i j k l m n p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9"
rem Create an "array" with the elements of the alphabet
set "size=0"
for %%a in (%alphabet%) do (
set "a.!size!=%%a"
set /a "size+=1"
)
rem Generate the output, selecting 32 randoms elements from the array
set "k="
for /l %%a in (1 1 32) do (
set /a "r=!random! %% size"
for %%b in (!r!) do set "k=!k!!a.%%b!"
)
echo(%k%
endlocal
%output%>C:\ME\Desktop\Gen.txt
答案 0 :(得分:0)
使用两个重定向符号>>
一个人会轻易覆盖所以使用两个
@echo off
setlocal enableextensions enabledelayedexpansion
rem Define alphabet
set "alphabet=a b c d f g h i j k l m n p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9"
rem Create an "array" with the elements of the alphabet
set "size=0"
for %%a in (%alphabet%) do (
set "a.!size!=%%a"
set /a "size+=1"
)
rem Generate the output, selecting 32 randoms elements from the array
set "k="
for /l %%a in (1 1 32) do (
set /a "r=!random! %% size"
for %%b in (!r!) do set "k=!k!!a.%%b!"
)
echo (!k!
echo(!k!>>"C:\ME\Desktop\Gen.txt"
Pause>null
endlocal
此外,如果启用了延迟扩展,则使用!包含变量引用!而不是%