Questions tagged [findstr]

findstr is a Windows command that searches for patterns of text in one or more files using regular expressions.

Useful links:

  1. FINDSTR on technet.
  2. FINDSTR on SS64 help pages.
730 questions
-1
votes
1 answer

Create Batch Script to Scan Multiple Files

I'm looking to make a batch script. What I have is a ton of different logs in a ton of different places, all with a bit of important info and a lot of useless info. Some of these logs are directly named, and some are named by date and time. I'm…
-1
votes
3 answers

Get a string in a line with a string pattern (CMD) - Windows Batch

I'm using windows command prompt (cmd). I have this file "myfile.txt" and i want to get the string in each line that match my pattern. For instance, if i have this in "myfile.txt": The file alpha_123.txt has been created The file gama_234.txt has…
reiver
  • 117
  • 1
  • 8
-1
votes
2 answers

Windows Cmd findstr - Regex with digits not working

I'm trying to validate if the IP address argument passed to a batch file is valid or not. Unfortunately, Windows findstr is not reliably working though the regex fed into is matched. Following is the summary of all the results. findstr sets…
Manohar M
  • 3
  • 2
-1
votes
1 answer

How do I use For /F in a batch file to find file types

I have a batch file which uses a For /F loop to find all files with a specific (cadence backup uses for backup) setup. For /F "delims=" %%A in ( 'Dir /B/S "*,*" ^| findstr ",[0-9][0-9]*$" ' ) Do Del "%%A" and this works for this…
tmd63
  • 21
  • 4
-1
votes
1 answer

Search folder name in whole disk/subfolders via FINDSTR by one line cmd?

I need to find just a folder wwwroot in whole disk F , and not files. Only folder. Is that possible by one line in cmd?
JaneFarrow
  • 101
  • 2
  • 10
-1
votes
2 answers

convert Linux grep command to windows

i would like to get help to convert this search string to windows command : grep taapAccessTokenTrustedAudiences * | grep -v credentials | grep -v application-cloud.yml
-1
votes
4 answers

FINDSTR to find text START END of string

I have string photo="999" price="10" category="1" . I want to get only 10. This means I need to the string which start price=" and ends with " @For /F "Tokens=1*Delims==" %%A In ('FindStr /I "^price=" "C:\price.txt" 2^>NUL')Do @Set…
-1
votes
1 answer

Delete textline with findstr

I have moved the file which has lines starting with specific text through the code below. It was possible until this, but I want to delete the text except for the lines with only specific text, but I don't know what to do. for /f %%a in ('findstr…
KDH
  • 3
  • 4
-1
votes
1 answer

Batch file putting numbers from a findstr output into variables for IF statement?

I have a log file with the relevant parts isolated with findstr separately, like this: 22 removed 0 updated The numbers change and have spaces in front of them and I'd like to get only the numbers into variables so that I could compare them…
Tarhonyaa
  • 51
  • 1
  • 3
-1
votes
1 answer

For /F findstr set value second column of CSV

I use a code to remove all files in a folder that contain some words saved in a CSV file. This code reads every line of my CSV file, and after searches every word read in CSV and delete the files that in our source have these word. Now I need to…
camomillo
  • 41
  • 1
  • 6
-1
votes
1 answer

Batch Script check a file for a string in a IF DO loop

new here and hoping this is an easy question. I have very little background in programming and scripting but I've got the basics working so far and I'm stuck. The logic of what I'm trying to accomplish with the parts marked I need help with; scan…
Solonor
  • 1
  • 2
-1
votes
4 answers

RegEx works on Online Simulator but not inside BatchFile with findstr

I was trying to setup a batch-file that uses findstr to kill all lines with a certain pattern. The sourcefile i want to analyse looks like this (i changed all values except of the 16th to numbers, usually they are names, urls, empty or single…
-1
votes
1 answer

How do I optimize findstr for sorted values

Let's say I have huge text file which has rows in format like Id Name Address All the records are sorted by Id. If I am searching for an Id, how would I make it more efficient to search using findstr or write something better than findstr?
sachin saner
  • 109
  • 1
  • 1
  • 11
-1
votes
1 answer

How to count the occurrence of a variable in log file matching a pattern/RegEx in windows batch script

I'm trying to store number occurrence of a value to count variable. set ATTR_TO_VERIFY=W10SBRS for /F "tokens=*" %%N in ('findstr /r "^<.*^>.*%ATTR_TO_VERIFY%.*:" lofile.log ^| find /v "" /c') do set "COUNT=%%N" echo %COUNT% but count always give…
Nishabu
  • 134
  • 1
  • 15
-1
votes
2 answers

How to replace @DLOG_ETS=ON by @DLOG_ETS=OFF in all *.opr and *.eng files?

I've created a simple batch file that searches in files with extension .opr and .eng for the term @DLOG_ETS and replace it with @DLOG_ETS=OFF. This may be redundant for cases where the full string is @DLOG_ETS=OFF. I want to add the condition that…