Loading ...
Sorry, an error occurred while loading the content.

How to get findstr avoid these characters < >

Expand Messages
  • gfunk99999
    Hi All, Mic Long time no see, Does anyone know how to get findstr avoid these characters (greater and lesser sign) inside a text file? In a
    Message 1 of 9 , Oct 12, 2006
    • 0 Attachment
      Hi All, Mic Long time no see,

      Does anyone know how to get findstr avoid these characters (greater and
      lesser sign) < > inside a text file? In a batch I just use
      ^ but in a text file I can't figure it out. After execution I get this
      error "The system cannot find the file specified." If I remove the < >
      characters the code executes without problems.

      Code:

      for /f "delims=" %%a in ('findstr /r /c:"Downloads" %temp%\summary.txt')
      do set download=%%a
      echo %download%

      summary.txt - Notepad
      Volume in drive C is IBM_PRELOAD
      Volume Serial Number is B4EE-2A1B

      Directory of C:\Documents and Settings\All Users\Application Data\Net

      10/10/2006 12:58 PM <DIR> .
      10/10/2006 12:58 PM <DIR> ..
      10/10/2006 04:19 PM <DIR> Downloads
      10/10/2006 12:59 PM <DIR> Logging
      10/10/2006 04:20 PM <DIR> Storage
      0 File(s) 0 bytes
      5 Dir(s) 13,590,061,056 bytes free






      [Non-text portions of this message have been removed]
    • Marc Peterson
      When I run this, the variable %download% is being set correctly and the error occurs with the ECHO command. I don t know if this will cause problems in your
      Message 2 of 9 , Oct 12, 2006
      • 0 Attachment
        When I run this, the variable %download% is being set correctly and the
        error occurs with the ECHO command. I don't know if this will cause
        problems in your application, but one way around this is to use:
        echo "%download%
        or
        echo "%download%"

        Marc

        > -----Original Message-----
        > From: batchworld@yahoogroups.com
        > [mailto:batchworld@yahoogroups.com] On Behalf Of gfunk99999
        > Sent: Thursday, October 12, 2006 2:43 AM
        > To: batchworld@yahoogroups.com
        > Subject: [BATCH WORLD] How to get findstr avoid these characters < >
        >
        >
        > Hi All, Mic Long time no see,
        >
        > Does anyone know how to get findstr avoid these characters
        > (greater and
        > lesser sign) < > inside a text file? In a batch
        > I just use
        > ^ but in a text file I can't figure it out. After execution
        > I get this
        > error "The system cannot find the file specified." If I
        > remove the < >
        > characters the code executes without problems.
        >
        > Code:
        >
        > for /f "delims=" %%a in ('findstr /r /c:"Downloads"
        > %temp%\summary.txt')
        > do set download=%%a
        > echo %download%
        >
        > summary.txt - Notepad
        > Volume in drive C is IBM_PRELOAD
        > Volume Serial Number is B4EE-2A1B
        >
        > Directory of C:\Documents and Settings\All
        > Users\Application Data\Net
        >
        > 10/10/2006 12:58 PM <DIR> .
        > 10/10/2006 12:58 PM <DIR> ..
        > 10/10/2006 04:19 PM <DIR> Downloads
        > 10/10/2006 12:59 PM <DIR> Logging
        > 10/10/2006 04:20 PM <DIR> Storage
        > 0 File(s) 0 bytes
        > 5 Dir(s) 13,590,061,056 bytes free
      • gfunk99999
        echo %download% worked. Thank you! Man O Man one simple quote... LOL ... and the ... cause ...
        Message 3 of 9 , Oct 12, 2006
        • 0 Attachment
          echo "%download% worked. Thank you! Man O Man one simple quote...
          LOL


          --- In batchworld@yahoogroups.com, "Marc Peterson"
          <marc.peterson@...> wrote:
          >
          > When I run this, the variable %download% is being set correctly
          and the
          > error occurs with the ECHO command. I don't know if this will
          cause
          > problems in your application, but one way around this is to use:
          > echo "%download%
          > or
          > echo "%download%"
          >
          > Marc
          >
          > > -----Original Message-----
          > > From: batchworld@yahoogroups.com
          > > [mailto:batchworld@yahoogroups.com] On Behalf Of gfunk99999
          > > Sent: Thursday, October 12, 2006 2:43 AM
          > > To: batchworld@yahoogroups.com
          > > Subject: [BATCH WORLD] How to get findstr avoid these characters
          < >
          > >
          > >
          > > Hi All, Mic Long time no see,
          > >
          > > Does anyone know how to get findstr avoid these characters
          > > (greater and
          > > lesser sign) < > inside a text file? In a batch
          > > I just use
          > > ^ but in a text file I can't figure it out. After execution
          > > I get this
          > > error "The system cannot find the file specified." If I
          > > remove the < >
          > > characters the code executes without problems.
          > >
          > > Code:
          > >
          > > for /f "delims=" %%a in ('findstr /r /c:"Downloads"
          > > %temp%\summary.txt')
          > > do set download=%%a
          > > echo %download%
          > >
          > > summary.txt - Notepad
          > > Volume in drive C is IBM_PRELOAD
          > > Volume Serial Number is B4EE-2A1B
          > >
          > > Directory of C:\Documents and Settings\All
          > > Users\Application Data\Net
          > >
          > > 10/10/2006 12:58 PM <DIR> .
          > > 10/10/2006 12:58 PM <DIR> ..
          > > 10/10/2006 04:19 PM <DIR> Downloads
          > > 10/10/2006 12:59 PM <DIR> Logging
          > > 10/10/2006 04:20 PM <DIR> Storage
          > > 0 File(s) 0 bytes
          > > 5 Dir(s) 13,590,061,056 bytes free
          >
        • Garry Deane
          ... Data Net ... In addition to using double quotes around %download% as already mentioned, you can also deal with poison characters as follows: 1. Keep
          Message 4 of 9 , Oct 12, 2006
          • 0 Attachment
            --- In batchworld@yahoogroups.com, "gfunk99999" <gfunk99999@...>
            wrote:
            >
            >
            > Hi All, Mic Long time no see,
            >
            > Does anyone know how to get findstr avoid these characters
            > (greater and lesser sign) < > inside a text file? In a batch
            > I just use ^ but in a text file I can't figure it out. After
            > execution I get this error "The system cannot find the file
            > specified." If I remove the < >
            > characters the code executes without problems.
            >
            > Code:
            >
            > for /f "delims=" %%a in (
            > 'findstr /r /c:"Downloads" %temp%\summary.txt')
            > do set download=%%a
            > echo %download%
            >
            > summary.txt - Notepad
            > Volume in drive C is IBM_PRELOAD
            > Volume Serial Number is B4EE-2A1B
            >
            > Directory of C:\Documents and Settings\All Users\Application
            Data\Net
            >
            > 10/10/2006 12:58 PM <DIR> .
            > 10/10/2006 12:58 PM <DIR> ..
            > 10/10/2006 04:19 PM <DIR> Downloads
            > 10/10/2006 12:59 PM <DIR> Logging
            > 10/10/2006 04:20 PM <DIR> Storage
            > 0 File(s) 0 bytes
            > 5 Dir(s) 13,590,061,056 bytes free
            >

            In addition to using double quotes around "%download%" as already
            mentioned, you can also deal with "poison" characters as follows:

            1. Keep the echo command within the scope of the FOR loop but use
            "echo %%a" e.g.

            for /f "delims=" %%a in (
            'findstr /r /c:"Downloads" %temp%\summary.txt') do (
            set download=%%a
            echo %%a
            )

            2. Replace the < and > characters with ^< and ^> e.g.
            for /f "delims=" %%a in (
            'findstr /r /c:"Downloads" %temp%\summary.txt') do set download=%%a
            set "download=%download:<=^<%"
            set "download=%download:>=^>%"
            echo %download%

            Garry
          • foxidrive
            ... Glad to see you got a solution. I m not sure you ll see this as it appears that I am being moderated... -- Regards, Mic
            Message 5 of 9 , Oct 12, 2006
            • 0 Attachment
              On Thu, 12 Oct 2006 07:42:49 -0000, gfunk99999 wrote:

              > Hi All, Mic Long time no see,

              Glad to see you got a solution. I'm not sure you'll see this as it appears
              that I am being moderated...

              --
              Regards,
              Mic
            • foxidrive
              ... I might have been too hasty making that judgement. I ve played around with using gmail, had my yahoo groups mail bouncing for various periods, added a
              Message 6 of 9 , Oct 13, 2006
              • 0 Attachment
                On Fri, 13 Oct 2006 13:17:56 +1000, foxidrive wrote:

                > On Thu, 12 Oct 2006 07:42:49 -0000, gfunk99999 wrote:
                >
                >> Hi All, Mic Long time no see,
                >
                > Glad to see you got a solution. I'm not sure you'll see this as it appears
                > that I am being moderated...

                I might have been too hasty making that judgement. I've played around with
                using gmail, had my yahoo groups mail bouncing for various periods, added a
                second email address (which seems to send back to the second address as
                well, hence my confusion as it must have bounced). Sorry, Sam.

                I can't even find the original of the email I sent - must be old farts
                disease. ;)

                The following was the gist of my post, leaving out the names I called BobB
                and MickieM ;) :

                I propose a batch file contest - I will start the bar low with something I
                use to look up a word in a dictionary - the fine freeware program WordWeb
                will define the word in clipboard when it starts up, saving time and
                typing.

                I call mine WW.BAT (for NT and later) and WordWeb can be downloaded from
                http://wordweb.info/

                @echo off
                start "" "c:\Program Files\WordWeb\wwnotray.exe" %*


                --
                Regards,
                Mic
              • Bob Bissinnar
                At 11:31 PM 10/13/2006 +1000, foxidrive Writes ... Greetings Mic, I apologize to you and the group for my delayed responses but I been so busy deleting and
                Message 7 of 9 , Nov 4, 2006
                • 0 Attachment
                  At 11:31 PM 10/13/2006 +1000, foxidrive Writes

                  >> that I am being moderated...

                  Greetings Mic,
                  I apologize to you and the group for my delayed responses but I been so
                  busy deleting and censoring your group posts (Thanks Sam!) and personal email.

                  Mic, I also canceled your pre-paid membership to Paranoia.org. Paypal
                  executives say they will provide you a full refund.

                  >I can't even find the original of the email I sent - must be old farts
                  >disease. ;)

                  Oldtimers disease Mic, that's what you have. Not to be confused with
                  Alzheimer which is a great way to meet new friends!

                  >The following was the gist of my post, leaving out the names I called BobB
                  >and MickieM ;) :

                  I can deal with the name calling "Stick and Stones....." but Poopy-head?

                  >I propose a batch file contest - I will start the bar low..
                  >@echo off
                  >start "" "c:\Program Files\WordWeb\wwnotray.exe" %*

                  The above batch file from Mic takes my breath away! I am grateful for my
                  training from French obstetrician Ferdinand Lamaze.

                  I propose to make Mic's batch file contest even lower than a snake's belly
                  in a wagon wheel rut.

                  Here's my contribution:

                  ::new batch file
                  :start
                  @echo on
                  @echo off
                  start "" "c:\Program Files\WordWeb\wwnotray.exe" %*

                  Game On Mic!

                  love you brother!
                • foxidrive
                  ... you dog-blasted, ornery, no-account, long-eared varmint! Take that [blam] and that [blam]. (holsters pistol) ...
                  Message 8 of 9 , Nov 4, 2006
                  • 0 Attachment
                    On Sat, 04 Nov 2006 13:33:59 -0500, Bob Bissinnar wrote:

                    > At 11:31 PM 10/13/2006 +1000, foxidrive Writes

                    > I apologize to you and the group for my delayed responses but I been so
                    > busy deleting and censoring your group posts (Thanks Sam!) and personal email.

                    <Yosemite Sam voice> you dog-blasted, ornery, no-account, long-eared
                    varmint! Take that [blam] and that [blam]. (holsters pistol)</Yosemite Sam
                    voice>

                    > I propose to make Mic's batch file contest even lower than a snake's belly
                    > in a wagon wheel rut.

                    >::new batch file
                    >:start
                    > @echo on
                    > @echo off
                    > start "" "c:\Program Files\WordWeb\wwnotray.exe" %*

                    I'll see you and raise you

                    ::new batch file mark 2
                    :start
                    @echo on
                    @echo off
                    rem
                    start "" "c:\Program Files\WordWeb\wwnotray.exe" %*



                    > love you brother!

                    Shhh. Mum told us never to speak of her dalliance with your dad...

                    --
                    Regards,
                    Mic
                  • Bob Bissinnar
                    At 12:52 PM 11/5/2006 +1100, foxidrive Writes ... @echo on @echo off rem pause start c: Program Files WordWeb wwnotray.exe %* ... Learned my lesson a few
                    Message 9 of 9 , Nov 6, 2006
                    • 0 Attachment
                      At 12:52 PM 11/5/2006 +1100, foxidrive Writes
                      >I'll see you and raise you
                      >::new batch file mark 2
                      >:start
                      > @echo on
                      > @echo off
                      > rem
                      > start "" "c:\Program Files\WordWeb\wwnotray.exe" %*

                      ::new batch file mark 3
                      :start
                      @echo on
                      @echo off
                      rem
                      pause
                      start "" "c:\Program Files\WordWeb\wwnotray.exe" %*



                      >> love you brother!
                      >Shhh. Mum told us never to speak of her dalliance with your dad...

                      Learned my lesson a few years ago, Mic. I always swallow all liquids
                      before reading one of your replies. Too funny, LMAO!
                    Your message has been successfully submitted and would be delivered to recipients shortly.