Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Substrings of tokens  (Read 2064 times)

0 Members and 1 Guest are viewing this topic.

Herkimer

  • Guest
Substrings of tokens
« on: October 16, 2007, 08:14:58 AM »
I am trying to use DOS to filter lines from one file to another.

I have the list of registered dlls from a system in the file Regfiles_sys1.txt in this format:

junk1.dll   {0000000} C:\Program Files\jnk\Junk1.dll [Junk 1.0 Type Library]
junk2.dll   {0000000} D:\Program Files\jnk\Junk2.dll [Junk 2.0 Type Library]
junk3.dll   {0000000} C:\Program Files\jnk\Junk3.dll [Junk 3.0 Type Library]
one.dll      {0000000} D:\Program Files\jnk\one.dll [one Type Library]

I only want the c:\ records in the new output file.

This is my code snippet so far which does not work:

for /F "usebackq" %%i in (`dir /b regfiles_*.txt`) do (call :No_D %%~ni)
goto :EOF

:No_D
   if {%1}=={} goto :EOF
   if exist %1.tmp del %1.tmp

   for /F "tokens=1,2* delims=}" %%i in (%1.txt) do (
      if /i "%%j:~0,3%" NEQ " d:" (echo %%i}%%j>>%1.tmp)
   )
   goto :EOF


^John
P.S. I do not know how to use the delay translate (!) or if it will help here.

ghostdog74



    Specialist

    Thanked: 27
    Re: Substrings of tokens
    « Reply #1 on: October 16, 2007, 08:40:59 AM »
    I only want the c:\ records in the new output file.

    Code: [Select]
    findstr /I "c:\\" file > newfile

    Herkimer

    • Guest
    Re: Substrings of tokens
    « Reply #2 on: October 16, 2007, 10:58:13 AM »
    Thank you.
    It works but my actual problem is a little more comlpex.

    I could Pipe a few of these together to do more tuning I guess.

    I was hoping for a more programmatic option so it could be customized to the situation.