We can nest most of the code within a couple more If statements to skip TXT and HTML files: if /I NOT "!FILENAMECHECK:~-4!"==".txt" ( if /I NOT "!FILENAMECHECK:~-5!"==".html" ( I also simplified your Microsoft Security Essentials file processing using the variable !SETUPPATH!, which allows you to make similar adjustments to files you may add in the future. Here is the final code with all modifications. It is untested. set /a NUM=0 if not exist "%WIM%\Windows\Setup\Updates" mkdir "%WIM%\Windows\Setup\Updates" >nul FOR %%f IN ("*.*") DO ( set "FILENAMECHECK=%%f" if /I NOT "!FILENAMECHECK:~-4!"==".txt" ( if /I NOT "!FILENAMECHECK:~-5!"==".html" ( set /a ROENUM=!NUM!*5 If !ROENUM! LSS 10 (set "ROESTR=00!ROENUM!") ELSE ( If !ROENUM! LSS 100 (set "ROESTR=0!ROENUM!") ELSE ( set "ROESTR=!ROENUM!")) set "SWITCH=/q" set "NAME=%%f" set "SETUPPATH=%%f" if /I "!FILENAMECHECK:~-4!"==".exe" ( if /I "!FILENAMECHECK:~0,7!"=="DirectX" ( set "SWITCH=/Q /T:\"%WinDir%\Setup\Updates\DX\" /C:\"%WinDir%\Setup\Updates\DX\dxsetup.exe /silent\"" set "NAME=DirectX Redistributable") if /I "!FILENAMECHECK:~0,15!"=="GamesForWindows" ( set "NAME=Games for Windows - LIVE") if /I "!FILENAMECHECK:~0,11!"=="Silverlight" ( set "NAME=Microsoft Silverlight") if /I "!FILENAMECHECK:~0,16!"=="windows-kb890830" ( set "NAME=Malicious Software Removal Tool") if /I "!FILENAMECHECK:~0,7!"=="wlsetup" ( set "SWITCH=/silent" set "NAME=Windows Live Essentials") if /I "!FILENAMECHECK:~0,8!"=="rootsupd" ( set "NAME=Root Certificates Update") if /I "!FILENAMECHECK:~0,4!"=="msse" ( set "NAME=Microsoft Security Essentials" "%%f" /Q /X:"%WIM%\Windows\Updates\MSSE" set "SETUPPATH=MSSE\setup.exe" set "SWITCH=/s /runwgacheck /o") ) if /I "!FILENAMECHECK:~-4!"==".msi" ( if /I "!FILENAMECHECK:~0,11!"=="PlayReadyPC" ( set "SWITCH=/quiet /norestart" set "NAME=PlayReady PC Runtime")) REG ADD %ROE%\!ROESTR! /ve /d "!NAME!" /f >nul REG ADD %ROE%\!ROESTR! /v "!NAME!" /d "%WinDir%\Setup\Updates\!SETUPPATH! !SWITCH!" /f >nul If /I "!SETUPPATH!"=="%%f" (copy /Y "%%f" "%WIM%\Windows\Setup\Updates")>nul set /a NUM+=1 )) )