Batch File To search file extension

March 19, 2009 at 02:43:01
Specs: Windows XP
Hi,

I need a Batch File to search files with the extension ".glb" in a specified directory, and if any one of the files has the extension as ".glb", i need to store the entire file name to a variable for further processing of the specific file such as converting the file to an xml file.

How do i do ahead with these ? Plz. help.

Thanks in advance,
Ashwin


See More: Batch File To search file extension

Report •


#1
March 19, 2009 at 05:24:17
@echo off & cls

::get list of files
dir *.glb /b > result.txt

::set result of list into variables
set count=1
setlocal enabledelayedexpansion
for /f %%a in (result.txt) do (
set line=%%a
set var!count!=!line!
set /a count +=1
)

::for testing pruposes only
echo %var1%
echo %var2%
echo %var3%
echo %var4%
echo %var5%
echo %var6%
:: etc......
pause>nul
del result.txt


Report •

#2
March 19, 2009 at 05:46:10
hey Thanks lee... it worked perfectly.... :)

i tried with the below command,

for /f "tokens=*" %%e in ('dir "C:\Program Files\Java\jdk1.6.0_12\bin\tmp\bar\*.glb" /b ') do echo %%e

its working too... :)

Thanks again for the quick help


Report •

#3
March 19, 2009 at 05:50:59
I am glad it worked! Yours was better!
cheers

Report •

Related Solutions


Ask Question