Solved using findstr to remove a stored variable from .txt?

May 17, 2014 at 11:33:26
Specs: Windows 7
Contents of filem.txt

Contents of dirm.txt:


I use this code to remove the 1st line from filem.txt but am unable to remove part of the second line so that only the directory name gets removed:

set vidas=0
for /F "tokens=*" %%A in (dirm.txt) do (
SET /A vidas=!vidas! + 1
set par!vidas!=%%A

findstr /x /v %par1% filem.txt >> z1.txt & del filem.txt & rename z1.txt filem.txt

How can I use findstr so that it removes e:\bad\a\ and leaves only the word b2.jpg in filem.txt. Tried a lot of conbinations, none worked.

See More: using findstr to remove a stored variable from .txt?

Report •

May 17, 2014 at 21:35:15
✔ Best Answer
There''re too many ambiguities to post a positive solution. So here's this to experiment with:
@echo off & setlocal
:: I just "faked" this next line
for /f "tokens=*" %%a in ("e:\bad\a") do set f=%%~dpnxa
echo F=%f%
for /f "tokens=*" %%a in (ssnader6) do (
echo drive+path=%%~dpa
echo name+ext=%%~nxa
set test=%%a
set test=!test:%f%=!
echo test=!test!

Report •
Related Solutions

Ask Question