我在txt文件中有一个名为conts.txt的大洲名称列表:
africa
america
asia
australia
europe
我如何创建批处理文件,在其中创建新的txt文件或重新创建conts.txt文件,并在文件中使用大洲名称的随机顺序。
谢谢,抱歉我的英语不好
编辑:纠正和向礼仪主义者道歉
我有批处理脚本,它将创建一个文件txt,其中包含按我的订单列出的大洲名称:
@echo off
set list=africa america asia australia europe
(for %%a in (%list%) do (
echo %%a
))>conts.txt
以及使用我的基本示例脚本,如何创建随机订单列表名称
您可以使用随机数创建第二个列表,然后根据该随机数对该列表进行排序:
@echo off
setlocal enabledelayedexpansion
set list=africa america asia australia europe
rem Output the list first
(for %%a in (%list%) do (
rem Add a number to each line to sort by
set num=00000!random!
set num=!num:~-5!
echo !num!:%%a
))>conts_.txt
rem Run through the sorted file and output the second part
(for /f "usebackq tokens=2 delims=:" %%a in (`sort Conts_.txt`) do (
echo %%a
)) > conts.txt
rem Delete the temp file
del Conts_.txt
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句