我是新来的一批,我想做到以下几点:如何扫描文件夹并将所有文件名存储在数组变量中,然后遍历数组?
- 读取或扫描的文件夹
- 保持在文件夹中的所有文件名中的一个数组变量(需要带或不带扩展名持有文件名)
- 循环访问该数组,并使用IF或CASE语句条件根据文件类型创建对特定文件/ bat的调用。例如:如果文件名中包含person一词,请调用特定文件/ bat。
这是我到目前为止有:
@echo off
setlocal EnableDelayedExpansion
rem Populate the array with existent files in folder
set i=0
for %%b in (*.*) do (
set /A i+=1
set list[!i!]=%%b
)
set Filesx=%i%
rem Display array elements
for /L %%i in (1,1,%Filesx%) do echo !list[%%i]!
请使用适当的格式编写。 –
你可以看看这个[批量文件阵列创建/修改](http://stackoverflow.com/questions/38678498/batch-file-array-creation-modification/38680369#38680369) 这个也是= => [通过CMD打开一个文件,并显示在特定的编辑器中选择](http://stackoverflow.com/questions/38524510/open-a-file-through-cmd-and-display-the-selected-in-specific -editor/38525929#38525929) – Hackoo