For循环不计数-仅输出1个文件名

时间:2019-05-18 15:02:22

标签: loops batch-file for-loop timing

@echo off
EnableDelayedExpansion
REM Should Enable Delayed Expansion not fix this counting problem????

cls
REM Clear screen

set %in%='C:\Users\Ultron\Pictures\in'
set %out%='C:\Users\Ultron\Pictures\out_resize(x2.250000)'    
cd %in%
REM Obvious, right?


FOR /R %%G in (*.jpg) DO (
REM echo Pic found!


set GG=%%~nxG
REM Had a bit of a problem with setting variables
REM Windows Batch is even more complicated, than bash. Lol.

set outfile="%out:"=%\%GG%"
if exist %outfile% (
REM echo Output file: %outfile% already exists!
mspaint %outfile%
)

)

如果我运行此代码,并且%in%文件夹中有10个文件,则它将打开10次MSpaint(每次仅打开1次,因为它没有线程化)。但是,它始终按字母顺序打开LAST文件。该数字是正确的,但文件始终相同?这对我不起作用。我需要比较一下,如果文件存在于%out%中,如果不存在,则需要将%in%中的文件转换为与%out%不同的文件。但并非总是一遍又一遍地使用同一文件。 ;)

非常感谢!

0 个答案:

没有答案