ValerieMay
Beta member
- Messages
- 1
Win XP Home SP.3+
The purpose of the batch script below is to detect the drive letter of an installed optical device and if the disk in the device contains a specific file (in this case Nero.ico) copy it to a folder. I would like to exit the For loop when copying is complete, in other words when the copying is finished the loop is redundant so does not have to continue. Exit and Exit /B won't do it as they will cause the script to be exited, Goto and Call :sub will leave the loop "live". Is there a command just to exit a For loop when a condition is met?
The purpose of the batch script below is to detect the drive letter of an installed optical device and if the disk in the device contains a specific file (in this case Nero.ico) copy it to a folder. I would like to exit the For loop when copying is complete, in other words when the copying is finished the loop is redundant so does not have to continue. Exit and Exit /B won't do it as they will cause the script to be exited, Goto and Call :sub will leave the loop "live". Is there a command just to exit a For loop when a condition is met?
Code:
@echo off>%temp%\nero.ico
cls
setlocal enabledelayedexpansion
for %%1 in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
if exist %%1: (
fsutil fsinfo drivetype %%1:| find /i "cd-rom">nul && set cdrom=%%1
if exist !cdrom!:\nero.ico copy !cdrom!:\nero.ico f:\temp\ > nul
set cdrom=
)
)
:: more coding here.....