For do if exist loop
Posted: 27 Jul 2013 10:46
Could someone please assist with the correct syntax for this? It errors out after seeing the second file in the string if it doesn't exist.
Thank you,
for /f "tokens=*" %%X in (hal.dll halacpi.dll halmacpi.dll kernel32.dll ntdll.dll ntoskrnl.exe win32k.sys winload.exe winsrv.dll) do (if exist %%X (
echo %%X
if not exist %%X (
echo %%X does not exist.
) else (
Copy %%X C:\BOOTFILES\
)
)
)
Thank you,
for /f "tokens=*" %%X in (hal.dll halacpi.dll halmacpi.dll kernel32.dll ntdll.dll ntoskrnl.exe win32k.sys winload.exe winsrv.dll) do (if exist %%X (
echo %%X
if not exist %%X (
echo %%X does not exist.
) else (
Copy %%X C:\BOOTFILES\
)
)
)