windows - CMD Batch - Search for last occurence of character while looping through file -


i have .txt file loop through every line , spool file. ok no problem far. want not spool lines, have following criteria:

they contain more slashes. find last slash. after 1 search rest of string .*** (* = wildcard). if not found don´t spool, else spool.

input file content example:

c:/abc/abc/ c:/abc/abc/test.txt c:/eee/ c:/eee/test.cfg c:/test/abc/test/xxx/bbb/ccc/aaa/test.txt c:/test/abc/test/xxx/bbb/ccc/aaa/ 

output should like:

c:/abc/abc/test.txt c:/eee/test.cfg c:/test/abc/test/xxx/bbb/ccc/aaa/test.txt 

it not static, lines appear, should removed. thought finding last slash , take after , if there last thing ".***" if keep else don´t echo

i don´t want use other tools this. must done via native command-line functionality.

maybe can me out.

code:

 >output.txt ( /f "usebackq delims=" %%i in ("file.txt") ( set "line=%%i" setlocal enabledelayedexpansion rem somehting here don`t know how echo(!line!) ) ) 

just in 1 line using findstr , regular expression mode (\....$ means strings ending . followed 3 characters):

findstr /r \....$ file.txt 

result:

c:/abc/abc/test.txt c:/eee/test.cfg c:/test/abc/test/xxx/bbb/ccc/aaa/test.txt 

Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -