Quantcast
Viewing all articles
Browse latest Browse all 11372

for loop is not working

Hi,

I am using a if condition that will first check if the above command ran successfully if the errorlevel is 0 then execute the condition inside the if condition. My syntax is as follows

if %errorlevel%==0 ( for /f "delims=" %%x in ('dir /b/od C:\Folder ') do set recent=%%x
set FILE=%recent%

echo %FILE%

echo "hello world"
) else ( exit 1 
)

--------------------------

the for loop is finding the latest file inside the C:\Folder .

The for loop is working fine , if I remove the if condition, but failing when it is inside the if condition. 

Kindly help.

Thanks,

Ashis


Viewing all articles
Browse latest Browse all 11372

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>