Search code examples
batch-filefind

Batch find text with quotation marks


1.

i use code to find test in file

>nul find "uset g_save_format "2"" log.txt && (
  echo "uset g_save_format "2"" was found.
) || (
  echo "uset g_save_format "2"" was NOT found.
)

how to find the text with "" for example:

uset g_save_format "2"

2.

cd c:\
cd c:\users\%username%\Documents\
>nul find "uset g_save_format ""0""" config.cfg && (
  goto savepyt
) || (
  goto scsc
)

how to write my code with findstr?

I have a problem to save the path with findstr

findstr  /c:\users\%username%\Documents\ "uset g_save_format \"2\""

Solution

  • >nul find "uset g_save_format ""2""" log.txt && (
      echo "uset g_save_format "2"" was found.
    ) || (
      echo "uset g_save_format "2"" was NOT found.
    )
    

    In FIND (though it is not documented by MS) command quotes are escaped with quotes. You can try also with FINDSTR -

    findstr  /c:"uset g_save_format \"2\""