1.

Solve : how to compare two variable with nested for loop?

Answer»

hi all

I need to design a batch file. this file will compare two dirctories. One named "script" and contains script files with .oam extension. The oter named "jobs" and contains subfolders.

If the a subfolder names in "jobs" is as same as a script name in "script", then DELETE it.

I have this code

@echo off

set SDIR=c:\script
set jdir=c:\jobs

dir /a:-d /b %sdir% > slist.txt
dir /a:d /b %jdir% > dlist.txt

for /f %%X in (c:\slist.txt) do for /f %%y in (c:\dlist.txt) ...


In the nested for look I want to compare %%x and %%y+".oam". If they are same, I will delete %jdir%+"\"+%%y .

I dont know if my logic or designing is CORRECT or not. please give me any suggestion.figured it out


@echo off

set sdir=c:\script
set jdir=c:\jobs

dir /a:-d /b %sdir% > slist.txt
dir /a:d /b %jdir% > dlist.txt

for /f %%x in (c:\slist.txt) do for /f %%y in (c:\dlist.txt) do if %%x==%%y.oam rmdir /q %jdir%\%%y





Discussion

No Comment Found