Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 批处理循环不';不行。为什么?_Batch File - Fatal编程技术网

Batch file 批处理循环不';不行。为什么?

Batch file 批处理循环不';不行。为什么?,batch-file,Batch File,我需要帮助来修复我的批次 setlocal EnableDelayedExpansion rem Get existent *.jpg files and sort they in the right order for %%a in ('dir /b /a-d "%sourcedir%\*.jpg" ') do ( set /A seq=1000000001+%%~Na set file[!seq!]=%%a ) rem Generate div containers with g

我需要帮助来修复我的批次

setlocal EnableDelayedExpansion
rem Get existent *.jpg files and sort they in the right order
for %%a in ('dir /b /a-d "%sourcedir%\*.jpg" ') do (
   set /A seq=1000000001+%%~Na
   set file[!seq!]=%%a
)
rem Generate div containers with groups of 5 files each
set i=0
(for /F "tokens=2 delims==" %%a in ('set file[') do (
   set /A i+=1, iMOD5=i %% 5
   if !iMOD5! equ 1 (
      rem break point block <div container> open
      ECHO ^<div class="gallery-row"^>
   )
   ECHO ^<div^>^<a href='images/%%~NXa'^>^<img src='images/%%~NXa' /^>^</a^>^</div^>

   if !iMOD5! equ 0 (
      rem break point block </div container> closed
      echo ^</div^>
   )
)) >>%page%.html
rem Close the last div container, if any
if %iMOD5% neq 0 (
   echo ^</div^> >>%page%.html  
) 
setlocal EnableDelayedExpansion
rem获取存在的*.jpg文件,并按正确的顺序对它们进行排序
对于('dir/b/a-d”%sourcedir%\*.jpg“')中的%%a,请执行以下操作(
set/A seq=1000000001+%%~Na
设置文件[!seq!]=%%a
)
rem生成div容器,每组包含5个文件
集合i=0
(对于('set file[')中的/F“tokens=2 delims==”%%a do(
设置/A i+=1,iMOD5=i%%5
如果!iMOD5!等于1(
rem断点阻塞打开
回音^
)
回音^^^^^
如果!iMOD5!等于0(
rem断点闭塞
回音^
)
))>>%page%.html
rem关闭最后一个div容器(如果有)
如果%iMOD5%neq 0(
echo^>>%page%.html
) 

循环运行,但在第一行中,图像.jpg是emply!!!有什么想法吗?

看起来您错过了第一个
FOR
循环的
/F
开关,即这一行:

for %%a in ('dir /b /a-d "%sourcedir%\*.jpg" ') do (
应该是这样的

for /F %%a in ('dir /b /a-d "%sourcedir%\*.jpg" ') do (