extracting substring with Batch File

May 29, 2009 at 10:08:43
Specs: Windows XP
Hello all,

I am making a batch file to install firmware to a chip on a circuit board, and i need it to display the version number of the installed file after it has completed the installation.
The version number is within the name of the file.
C:\Documents and Settings\All Users\Documents\xilinx\Servo_Build(PCB3.0_2007-10-11-A).jed

I want to extract and display the part in parenthesis:

I am a batch-file amateur, so the simpler the explanation the better : )

Thanks in advance!

See More: extracting substring with Batch File

Report •

May 29, 2009 at 10:13:25
oh, one more detail.
the file (or the version number) will not always have the same number of characters, or be in that location. what i need to do is display the part in the parenthesis, regardless of how long the file name or version number is


Report •

May 29, 2009 at 13:09:22
@echo off & setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%a in ('dir/s/b/a-d c:\*.jed') do (
set n=%%~Na
for /f "tokens=2 delims=()" %%i in ("!n!") do (
set v=%%i
echo !v!

If at first you don't succeed, you're about average.


Report •

June 1, 2009 at 10:12:11
works perfectly!


Report •

Related Solutions

Ask Question