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
1
vote
1answer
60 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 [...
2
votes
1answer
83 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 ...
0
votes
1answer
26 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.
0
votes
2answers
91 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 ...
1
vote
0answers
16 views

Search txt-files for exact numbers with batchfile, findstr

I'm trying to search for exact numbers stored in textfiles 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 not getting false ...
1
vote
1answer
517 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 ...
1
vote
2answers
81 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,...
-1
votes
1answer
57 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 ...
0
votes
1answer
317 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 ...
1
vote
2answers
263 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 ...
4
votes
1answer
143 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 ...
0
votes
1answer
464 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 ...
1
vote
1answer
392 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 ...
1
vote
1answer
188 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 ...
0
votes
1answer
457 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 ...
0
votes
1answer
291 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 ...
0
votes
2answers
3k 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 ...
1
vote
1answer
9k 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 ...
0
votes
1answer
145 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?
0
votes
1answer
3k 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 ...
1
vote
1answer
2k 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 ...
0
votes
0answers
77 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"') ...
0
votes
1answer
441 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=%...
0
votes
1answer
4k 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 "...
3
votes
0answers
855 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 ...
1
vote
1answer
254 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 /...
0
votes
1answer
56 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 ...
2
votes
1answer
591 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 /...
7
votes
3answers
8k 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 ...
0
votes
1answer
636 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 ...
2
votes
2answers
7k 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....
3
votes
2answers
1k 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 > ...
1
vote
1answer
348 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\...
1
vote
1answer
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 ...
0
votes
1answer
632 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 ...
3
votes
1answer
10k 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 ...
1
vote
1answer
892 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 /...
1
vote
1answer
1k 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 ...
2
votes
1answer
471 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 ...
6
votes
3answers
38k 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. ...
2
votes
2answers
10k views

How to use FINDSTR to search in a specific line?

I have a file example.txt and a string "Hi" and the beginning of the 15th line. The required code for findstr should be: findstr /b /n "Hi" "example.txt" Is there something that can search for "Hi" ...
0
votes
0answers
1k views

Find “mystring” in files and return only certain portion of matching lines

I have below command to list out every file in current directory and it's sub-directories containing "mystring" along with the line where search string match is found. @echo off setlocal findstr /s ...
0
votes
1answer
415 views

Findstr: match filenames containing exactly a single dot

I am desparately trying to find all files within a folder and its subdirectories containing exactly a single dot. Reading the documentation of findstr I came up with this kind-of-regex, but it still ...
0
votes
1answer
56 views

find certain item of a file by using command line tool in windows 7

recently I used findstr "ItemThatIsBeeingSearchedFor" C:\Windows\System32\drivers\etc\hosts > J:\documents\HostsFile\ResultOfSearch.txt in order to output a certain entry of the hosts file into ...
2
votes
1answer
1k views

Get URL from HTML file using FindStr

I'd like to preface this by saying that I'm very new to the command prompt and I've been only using it for some WGET and YOUTUBE-DL, and that I'm on a Windows 8 PC. I'd like to get a bunch of links ...
2
votes
2answers
1k views

Most efficient command to search the first line of many files (windows)

I am new to the windows ecosystem. I have been tasked with writing a program that will search several 10's (maybe even 100's) of thousands of files for a particular string. The string that must be ...
2
votes
1answer
1k views

Delete scheduled taskname containing space

I want to delete scheduled tasks that start with "Adobe Acrobat" eg "Adobe Acrobat 123","Adobe Acrobat 456","Adobe Acrobat 789" schtasks /Delete /TN Adobe* /F This command fails to find any tasks ...
28
votes
2answers
81k views

findstr DOS Command's multiple string argument

findstr /v "black" File1.txt Above DOS command will display content of 'File1.txt' which are not matching string "black". How to modify this command , if I need to filter words "black" and "white" ?...
0
votes
1answer
714 views

Use findstr to output characters 1-13

I have the code: findstr /B ^121.*.CATDrawing catdrawing.txt How to show from the first to thirteenth character? 1220112000001A.CATDrawing -> 1220112000001
0
votes
2answers
4k views

Windows 7 cmd Findstr for 2 strings a AND b(not OR)

I want to know if there is a way to use findstr to find only those lines in a text file which have both strings a and b. The following: findstr "aaa bbb" test.txt will find all lines with aaa or bbb. ...