Questions tagged [findstr]

Use this for question about the DOS/cmd `findstr` command for searching for strings in files

Filter by
Sorted by
Tagged with
3 votes
2 answers
74 views

findstr /X keeps printing lines with no matches

I'm using nslookup and findstr in a simple batch script to check if a website is up. However findstr keeps printing lines which doesn't contain any matches. The command goes like this: nslookup ...
Mizuki's user avatar
  • 33
2 votes
3 answers
117 views

Seemingly impossible to extract URL string in between two text delimiters from 100's of messy Google News Alert emails with batch

For years Google News Alerts has sent daily emails when certain words pop up in websites, tweets, etc. and these emails (in HTML and .txt format) have one unique quality: there is no easy way to pull ...
user1798732's user avatar
0 votes
1 answer
399 views

How to get specific string with batch for loop when it is in a line below a string we search?

I have an issue I am not sure how to deal with. I need to search a txt file where the search string is on the top but the actual data needed is in the next line underneath. Example: So I just noticed ...
Robert Corlin's user avatar
1 vote
2 answers
211 views

How to quickly determine which files contain only NULLs so they can be safely deleted (Windows)?

A friend has thousands of files that likely contain nothing but NULLs (ASCII 0). (If interested, see this Super User QA to learn why). The files range in size from 650 bytes to ~200MB (with the ...
RockPaperLz- Mask it or Casket's user avatar
0 votes
1 answer
109 views

Copy Mac Address of the most recent networking device inserted in my computer! Possible?

I borrowed a batch script from another user on this site so that I can copy a Mac address automatically whenever I click it. But I need modifying the script. Here's the link. Copy Mac Address into ...
Rets86's user avatar
  • 1
6 votes
4 answers
3k views

Using 'ping' and 'findstr' in a 'for' loop of batch file first throws error not an internal external command but it again shows output

This batch file @echo off set path=C:\Users\ssiyengar\Desktop\Pingtest\pinglist.csv set file=C:\Users\ssiyengar\Desktop\Pingtest\temp.txt set qosping=1 cls for /f "tokens=1-3 delims=," %%a ...
Srivatsan's user avatar
0 votes
1 answer
38 views

Parse multiple servers for the latest modifed file within a subdirectory with a specific text within it

I have multiple servers having a specific folder name within which there are multiple subdirectories. I would like to look into the latest file within that subdirectory (each subdirectory will have a ...
Kumar's user avatar
  • 1
0 votes
1 answer
1k views

CMD - Manually enter a value and check if it exists in a .txt with multiple lines > reply the result

I am trying to create a batch file which will check a given term against an existing text file with multiple lines (10000+ lines). More specifically, I have a list of domains that I want to blacklist, ...
Phantom's user avatar
1 vote
1 answer
724 views

Findstr retuns an errorlevel code incorrect?

There is a file named myfile.txt contains the string "hpxu" Enter command prompt and I typing: findstr khry myfile.txt & echo %errorlevel% At first execution result is 0 at the second ...
adriansor's user avatar
2 votes
2 answers
608 views

Search term in specific line in multiple files

I would like to search a text in multiple files (within a directory) at a certain line number. Example: I have ~100 Script Files in a directory (C:\Scripts) and I would like to scan all of these files ...
SteffPoint's user avatar
1 vote
1 answer
717 views

How to get tab-initiated lines using Findstr /B [TAB] in Bat/CMD

There is an option that works in Unix & Linux: Like @jimmij answer command: grep -B2 '^\t' file. But is there an option using only bat/cmd with the Findstr command? Already tried.. Findstr /bl [...
Io-oI's user avatar
  • 7,695
2 votes
1 answer
609 views

Windows make all files in folder that contain a line read-only

I have some files in a directory with the comment: // _READONLY_ I'd like to set all these files to read-only using a batch script. I've found this command to set read-only status: attrib +r I know ...
Raymo111's user avatar
  • 127
0 votes
1 answer
727 views

Findstr : Search a string in files without extension

I want to search a string in files without extension. I've tried: findstr /s /m /c:"the_word_i_need_to_find" * But this command search in files with any extension.
flofreelance's user avatar
0 votes
2 answers
3k views

Find text in files and then rename the files, in Batch

i'm having some problems creating a script that find a specific text in each file inside a folder, get the content after that text and set it as a name for the file, all that inside a loop, to perform ...
Shane89's user avatar
1 vote
2 answers
901 views

Search txt-files for exact numbers with batchfile, findstr

I'm trying to search for exact numbers stored in text files using a batch file. The files are looking like this: 1, 2, 4, 11, 18, 19, 25, 35, 42, 66, 87, 89....... The problem is to avoid getting ...
Night Rider's user avatar
2 votes
1 answer
2k views

FINDSTR Multiple Search Strings [duplicate]

Looking for either word “ And ” or “ In ” with preceding and ending spaces, I can using following FINDSTR command: findstr /r /c:” And ” /c:” In “ textfile Is there a way to do similar search with ...
Sui's user avatar
  • 21
1 vote
2 answers
152 views

findstr 2 arguments and 2 events

I create a XML file from PRTG status monitor. in this XML file are values >4< for warning and >5< for error. With findstr and if errorlevel I can only check if one of the value is true or false,...
chriss chross's user avatar
-1 votes
1 answer
147 views

Searching for file in .bat

I want to delete all pdf files from a folder, that doesn't contain words "Times" OR "Wall" in their file names. So files 1.pdf 2.pdf All_Times_to_ride.pdf Wall.pdf are in and All_Times_to_ride.pdf ...
Kamil's user avatar
  • 1
0 votes
1 answer
2k views

How do to use Windows 'findstr' or other utility to find file containing a string featuring specific characters & of certain length?

I need to find any file across the entire file system that includes a string of text featuring between 30 & 40 consecutive characters only (i.e. it should match a md5 hash and not a sha512 hash ...
smoggers's user avatar
  • 123
1 vote
2 answers
991 views

how to extract a specific part of a string from character 7 to 17 and save it in new txt file (findstr, gnu32-sed or other tool)

How do I extract a specific part of a string from character 7 - 17 using regex via the command line? My string is ThisString and in the file data I have a lot of strings, but I need only ThisString ...
Tom's user avatar
  • 29
4 votes
1 answer
335 views

Is there a better way to mitigate this obscure color bug when piping to FINDSTR inside a parenthesized block of (.bat) code?

In the following .BAT file, test 2 demonstrates the color bug inside a parenthesized block of code, test 3 demonstrates the bug inside a FOR loop, and test 4 shows how the bug can be mitigated by ...
Dolores Stevens's user avatar
0 votes
1 answer
2k views

How to correctly write regex to findstr for cmd?

I am trying to only print UUID in windows and running following command: wmic csproduct get uuid | findstr /R “[a-zA-Z0-9]{5}-[a-zA-Z0-9]{5}-[a-zA-Z0-9]{5}-[a-zA-Z0-9]{5}” Above command returns ...
Ishan Patel's user avatar
1 vote
1 answer
878 views

Pipe error in [Echo !file!|findstr]

with this script I read a Log file with filenames and search a string (with wildcards) in these list but the pipe for the findstr function doesn't work. setlocal enabledelayedexpansion for /f %%A in ...
THxy's user avatar
  • 23
1 vote
1 answer
347 views

search a UCS-2 file using batch

I have a file that is encoded in UCS-2 that is constantly being updated. I need to keep checking this file for a string of recurring text and then parsing the info. I originally tried using findstr ...
Allan Ballard's user avatar
0 votes
1 answer
1k views

Become Windows 10 search compliant with the fuzzy matching?

Fuzzy matching allows some mistakes like inversion of two letter when you are searching a string. For sample, you want to find the files that contains the string: "Albert Einstein". The "fuzzy ...
user34837's user avatar
  • 179
0 votes
1 answer
636 views

findstr test if contains characters other thank given batch

I have a batch script where user input is needed. However, I only want to allow a-z, 0-9, @#$].~+-=_/\:;. Is there a way to use findstr to make sure there are no characters other than those? I've ...
Mark Deven's user avatar
  • 1,508
0 votes
2 answers
6k views

Excel check if combination of data exists in a certain range

See question 1337631 Check if a specific range of values in one dataset exists in another dataset This solution works great, but what if you want to check WITHIN the same range? Want to use this for ...
Daniel H's user avatar
2 votes
1 answer
15k views

Batch File, dir | findstr within a for loop

Let me preface by admitting that I am a complete noob at batch files... and programming language in general. I am trying to write a batch file that allows the user to input a partial filename, and it ...
Gumbi's user avatar
  • 23
0 votes
1 answer
366 views

How can I "findstr" all links from a source-code of a webpage?

I want to have just the https-Link in a seperate file. How do to that without getting the complete line of the code, just the links?
jsterr's user avatar
  • 431
0 votes
1 answer
5k views

findstr search including return character

Is there a way I can use findstr to search for: <char>Hello there my friend,</char> <continued>this is two lines of text</continued> I need to search for a string that ...
Mark Deven's user avatar
  • 1,508
1 vote
1 answer
5k views

Equivalent of a wildcard in find for batch?

I'm almost certain this is a duplicate but I was unable to find it after a lot of searching so forgive me. I'm looking for a way to have the equivalent of a wildcard in the find command. For ...
Mark Deven's user avatar
  • 1,508
0 votes
0 answers
105 views

How to echo color quotes in this batch function?

I have the following script with a colored echo function: @echo off setlocal EnableDelayedExpansion for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') ...
Mark Deven's user avatar
  • 1,508
0 votes
1 answer
753 views

Have another if option in the for loop in a batch file

I have this functioning For /F loop: Setlocal EnableDelayedExpansion for /F "tokens=*" %%A in (New.txt) do ( echo "%%A" | findstr /C:"[B]" 1>nul if !errorlevel!==1 echo "%%A" set line=%...
Mark Deven's user avatar
  • 1,508
0 votes
1 answer
6k views

How do I find files containing “string A” and NOT containing “string B” and output their names into a file?

I was looking at this other question, but wasn't sure how to combine these queries together. I started off with this, but it doesn't seem to work: findstr /S /M "string A" *.vb | findstr /S /M /V "...
thecoolmacdude's user avatar
3 votes
0 answers
2k views

find string from multiple files and replace it without creating new file

I want to find string e.g. "date" from my files of a folder which contains multiple ".c" and ".h" files in it and replace it with "date 24-April-2018" using batch file. what should do? Please see ...
Meera's user avatar
  • 31
1 vote
1 answer
284 views

Can't connect to a wireless network using cmd

Im trying to connect my phone to my PC via FTP and open the FTP with Windows Explorer using the cmd. Below are the codes: @echo off echo Setup connection to ftp 192.168.43.1 ipconfig | findstr /...
Xlam's user avatar
  • 137
1 vote
1 answer
1k views

Find a string at the beginning of all lines in a file and save to another file

I have tried quite a few options with no luck for this task. I would really like to do this as batch file but my attempts fail to get the desired result. I have tried a lot of different commands with ...
JAH's user avatar
  • 23
2 votes
1 answer
1k views

grep -r (or -R) does not search inside subfolders

It has been some time since I don't use linux, using windows instead. In windows whenever I want to search for a string on files and files inside subfolders I do (for example for cs files) findstr /...
KansaiRobot's user avatar
8 votes
3 answers
16k views

FINDSTR: Line is too long

Windows FINDSTR command is useful for sifting through large amounts of data; it filters out lines of text that match or don't match a specified pattern or string (like GNU/BSD grep). But it refuses ...
voices's user avatar
  • 2,651
0 votes
1 answer
2k views

Searching for files within a number of folders in command line in Windows 10

I'm trying to find the proper syntax for finding all the files with a specific name that are in a multitude of folders. So - I have a directory with 100+ folders, in each folder there are files that ...
Sam's user avatar
  • 11
2 votes
2 answers
11k views

How do I extract the IPv4 IP Addresses from the output of ipconfig, and then filter it so that my output only includes a list of the IP addresses?

How do I extract the IPv4 IP Address from the output of ipconfig I read through this post and it was very helpful. I was just wondering if the is a way I can extract only the IP Addresses (xxx.xxx....
Hassan Daudzai's user avatar
3 votes
2 answers
2k views

A powershell version of for /f (|findstr) for Unicode folders/files

Here is a small script I wrote that recursively scan a directory without some parent-subdirectories and extracts some attributes of the files within it. @echo off echo Path,Name,Extension,Size > ...
Roey Peretz's user avatar
1 vote
1 answer
531 views

Windows Find Regex - findstr LookBehind

I have this string: DisplayName REG_SZ Paquete de controladores de Windows - Intel Corporation (iaStorA) HDC (07/22/2015 14.5.2.1088) Which I have taken from: Reg Query HKLM\Software\...
aDoN's user avatar
  • 111
1 vote
1 answer
2k views

How to exclude a folder from a string search

>>"results\txtmail.txt" findstr /i /p /s mail %userprofile%\*.txt Now, what if I want to exclude C:\Users\Username\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.IE5 from the ...
Daniel's user avatar
  • 283
0 votes
1 answer
740 views

Copy /b and Findstr /v

I'm trying to merge a lot of logs together that is in one folder. This is what I've tried to do. copy /b *.log test.log | findstr /V "xyz" test.log >> final_test.log It doesn't seem to be ...
Yen Deng's user avatar
4 votes
1 answer
17k views

Use findstr to Search a Sub Directory for a String?

I can use the following to search for text files that contain the word "string" from the Windows Command Prompt: C:\>findstr /spin /c:"string" *.txt What if I want to search a sub-directory? The ...
GTS Joe's user avatar
  • 227
1 vote
1 answer
1k views

Windows XCOPY results from FIND command

Windows 7 CMD I can retrieve a list of files by the following command dir /b | find "TENDER_NUM 2". I'm trying to copy all the files that were returned by find into another folder. I've tried: for /...
BardsWork's user avatar
  • 141
1 vote
1 answer
2k views

Batch: Return the matching lines from pipe's output to the console with regex

I have the following domain checking bash script in Linux: #!/bin/bash TLD='.com' while read -r domain; do whois -H $domain$TLD | grep -oPaq '^.*(Creation Date|record created).*$' if [ $? -eq 0 ...
Lanti's user avatar
  • 139
2 votes
1 answer
821 views

How to go through a list of installed programs and take out any line with Microsoft-related strings?

This is on Windows 7 using command line and batch files. I was looking to examine my program list and uninstall a good amount of junk and update a good amount of outdated programs. I used a wmic ...
Zachary Johnson's user avatar
7 votes
5 answers
56k views

How do I extract the IPv4 IP Address from the output of ipconfig

I'm attempting to have cmd copy only a specific set of character from a command output. I've been able to select the line that the phrase exists in but from there I am lost. Here is my command so far. ...
Samuel Pauk's user avatar