Using for to search a folder and all its subfolders
Posted: 03 Apr 2010 12:17
is this possible? I have created a batch file that searches for all .vtf files without an according .vmt file. And creates a vmt for them.
It works perfectly other than you have to specify the subfolder where the certain textures are located. I want it to scan anything within the materials folder, and all its subfolders. This is required because many of the subfolders names change and new ones get added/removed. Sorry if im vague or confusing im in a hurry.
Heres the code i have now:
I appreciate any help, im quite the batch noob. :c
It works perfectly other than you have to specify the subfolder where the certain textures are located. I want it to scan anything within the materials folder, and all its subfolders. This is required because many of the subfolders names change and new ones get added/removed. Sorry if im vague or confusing im in a hurry.
Heres the code i have now:
Code: Select all
@echo off
:Menu
echo Batch file created by Pyromaniac1444, type the directory below...
set /p diry=Directory: C:\Steam\steamapps\pyromaniac1444\half-life 2\hl2\materials\
echo Finding all materials in %diry%...
for %%M in ("C:\Steam\steamapps\pyromaniac1444\half-life 2\hl2\materials\%diry%\*.vtf") do (
echo Scanning %%~nM...
if not exist %%~pM%%~nM.vmt (
echo "VertexLitGeneric" > %%~pM%%~nM.vmt
echo { >> %%~pM%%~nM.vmt
echo "$basetexture" "%diry%\%%~nM.vtf" >> %%~pM%%~nM.vmt
echo } >> %%~pM%%~nM.vmt
echo Missing vmt for file %%~nM, file %%~nM.vmt created.
)
)
echo -------------------------
echo File creation is complete!
echo -------------------------
pause
goto Menu
I appreciate any help, im quite the batch noob. :c