批量创建多行的数组 [英] Create an array in batch in multiple lines
问题描述
我想要的文件列表复制到使用批处理文件的特定目录。我需要做的第一件事情就是创建文件名的列表。我看到这个这个帖子在Windows中创建批处理列表或数组。以下的罚款。但我不开心的事实,它是一条线。由于我的文件列表变得越来越大,变得难以阅读。
I am trying to copy a list of files to a specific directory using a batch file. The first thing I need to do is to create a list of file names. I saw this this post Create list or arrays in Windows Batch. The following works fine. But I am not happy about the fact that it is in one line. As my list of files gets bigger and bigger, it becomes hard to read.
set FILE_LIST=( "file1.txt" "file2.txt" "file3.txt" )
然后,我注意到了这一点博客一>。它创建了多行的数组。
And then I noticed this blog. It creates an array with multiple lines.
set FILE_LIST[0]="file1.txt"
set FILE_LIST[1]="file2.txt"
set FILE_LIST[2]="file3.txt"
我想知道是否有创建一个数组以下的一种方式:
I am wondering whether there is a way of creating a array as the following:
set FILE_LIST=( "file1.txt"
"file2.txt"
"file3.txt" )
,这样我可以分开文件名成多行,而不必担心指数。
so that I can separate the file names into multiple lines, while do not need to worry about the index.
推荐答案
在同一主题的你是指有这个解决方案的当量(下面的你也可以创建一个数组这样):
In the same topic you refer to there is the equivalent of this solution (below "You may also create an array this way"):
setlocal EnableDelayedExpansion
set n=0
for %%a in ("file1.txt"
"file2.txt"
"file3.txt"
) do (
set FILE_LIST[!n!]=%%a
set /A n+=1
)
这篇关于批量创建多行的数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!