I need to loop through a set of files in a directory, matching a wildcard pattern and extract a portion of of the file name in between two other patterns. Unix (i.e. bash) equivalent command would be something like this:
ls -1 "$wildcard1"*"$wildcard2" | while read filename; do
string2find=`echo $filename | cut -d $delim1 -f2 | cut -d $delim2 -f1`
echo $string2find
#do something with string2find variable here
done
In batch file, I tried this
for %%f in (WILD1*WILD2) do (
echo %%f | cut -d_ -f2 | cut -d"." -f1> temp.out <--here, need something between an "_" and a "."
type temp.out <-- see the right string in the file
set var= <clear the variable
set /p var=<temp.out
echo %var% <-- ECHO is off message I am getting here
del temp.out
REM need to do something with var here
)
All the examples I was able to find is devoid of piped commands.