Questions tagged [findstr]
Use this for question about the DOS/cmd `findstr` command for searching for strings in files
70
questions
0
votes
0
answers
21
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 ...
0
votes
0
answers
78
views
Difference between Windows 10 'findstr' and 'Windows Search' regarding Unicode files
There seems to be a difference between two search tools in Windows 10. Specifically, the 'findstr' command can find text content encoded in UTF-8 and UTF-8 BOM, while 'Windows Search' can only find ...
0
votes
1
answer
74
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, ...
1
vote
1
answer
97
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 ...
2
votes
2
answers
177
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 ...
1
vote
1
answer
317
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
1
answer
171
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
1
answer
104
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
2
answers
1k
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
2
answers
326
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 ...
2
votes
1
answer
1k
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
2
answers
93
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
1
answer
59
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
1
answer
794
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
2
answers
629
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
1
answer
196
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
1
answer
633
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
1
answer
551
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
1
answer
274
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
1
answer
680
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
1
answer
340
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
2
answers
4k
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 ...
2
votes
1
answer
11k
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
1
answer
218
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
1
answer
4k
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
1
answer
3k
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
0
answers
87
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
1
answer
509
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
1
answer
5k
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
0
answers
1k
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
1
answer
263
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
1
answer
75
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
1
answer
736
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 /...
8
votes
3
answers
12k
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
1
answer
1k
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
2
answers
9k
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
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 > ...
1
vote
1
answer
407
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
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 ...
0
votes
1
answer
675
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
1
answer
12k
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
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 /...
1
vote
1
answer
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
1
answer
671
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
4
answers
44k
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
2
answers
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" ...
1
vote
0
answers
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
1
answer
485
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
1
answer
59
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
1
answer
2k
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 ...