gpt4 book ai didi

windows - 使用 ,[space] 加入 .txt 文件中的数字列表

转载 作者:可可西里 更新时间:2023-11-01 09:47:29 27 4
gpt4 key购买 nike

您好,我设法获得了下面的代码来创建一个数字列表,并在每个创建的数字的末尾放置一个逗号但是,事实证明,要让它们在同一行上由 ,[space] 分隔是一项相当大的挑战

@ECHO OFF
setlocal EnableDelayedExpansion
set _Output=%UserProfile%\Desktop\NumGen.txt

::only change these three lines
set "start=1" ::starts from this number
set "amount=10" ::amount of files created
set "length=5" ::length of fileNames
set "join_with=, " ::what to join each number with

set /a "last=%start%+%amount%"
for /l %%i in (%start%,1,%last%) do (
set "folderName=0000000000%%i"
set "folderName=!folderName:~-%length%!%join_with%"
>>"%_Output%" ECHO.!folderName!
)
pause

所以我现在的输出是

00001, 
00002,
00003,
00004,
00005,
00006,
00007,
00008,
00009,
00010,
00011,

但我希望它是这样的

00001, 00002, 00003, 00004, 00005, 00006, 00007, 00008, 00009, 00010, 00011

我有 windows 10 64 位。任何帮助将不胜感激

最佳答案

echo 无法做到这一点。但是有一个解决方法,(ab) 使用 set 命令:

for /l %%i in (1,1,5) do (
<nul set /p "=%%i, "
)
echo(

关于windows - 使用 ,[space] 加入 .txt 文件中的数字列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36567603/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com