3

我觉得这应该很容易做到,但我自己无法完全弄清楚。也许有人能够提供帮助。

我有这个小批量脚本,它基本上检查文件夹是否Folder1已经存在。如果没有,它将创建Folder1Folder6. 如果是这样,它只会回应这个事实。

@ECHO OFF
If not exist Folder1 (for /L %%a in (1,1,6) do md Folder%%a) else (ECHO Folder structure already exists)

我现在想做的是用If not exist Folder1更有意义的东西代替。IE。If not exist folder with any string greater or equal to 'Folder'

有什么办法我会这样做吗?

4

3 回答 3

2

不会

for /L %%a in (1,1,6) do md Folder%%a

更容易,并创建目录,无论它们是否已经存在?

for /L %%a in (1,1,6) do md Folder%%a 2>nul

应该抑制已存在目录的消息。

于 2013-06-29T15:26:16.420 回答
1

this might work for you:

rem if not exist folder
if not exist "folder1" (
    rem with any string greater or equal to 'Folder'
    if "folder1" geq "Folder" (
        rem do sth.
        rem do sth. more
    )
)
于 2013-06-29T15:29:46.183 回答
0
@echo off
set "flag="
for /L %%a in (1,1,6) do if not exist "Folder%%a\" set flag=1
if defined flag (
echo at least one of your folders is missing captain.
for /L %%a in (1,1,6) do md Folder%%a 2>nul
) else (
echo Warp speed, no folders to create
)
于 2013-06-30T09:53:37.297 回答