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
2answers
53 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 ...
2
votes
0answers
75 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
0answers
8 views

findstr skipping some files on Windows 10

For some reason, when I run the following command on Windows 10 some of the expected *.cpp files are missing from the output: findstr -siprm i *.cpp Removing the -s option or choosing to search all ...
0
votes
0answers
34 views

How to Replace a string in a file using windows batch

I have a file say C:/temp/example.xml The contents are as below. https://example.net/fndstring> https://example.net/fndstring> I need a windows batch command to find the line with string "The link"...
0
votes
1answer
205 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
211 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 ...
0
votes
1answer
97 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
240 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
238 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
1k 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
5k 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
89 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
2k 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
1k 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
75 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
341 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
3k 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
732 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
241 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
488 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 /...
3
votes
3answers
5k 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
212 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
5k 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
960 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
314 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
1k 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
542 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
8k 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
681 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
298 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 ...
5
votes
2answers
31k 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
8k 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
314 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
50 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
799 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 ...
22
votes
2answers
64k 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
524 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
2k 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. ...
0
votes
1answer
661 views

Batch to retrieve TFS version erroring in FOR /F where TFS attempts to PIPE to findstr

I have this partial batch, but it gives me an error (On 64 bit installations) SETLOCAL EnableDelayedExpansion REM Figure out what ProgramFiles Root we run the command SET ProgFiles86Root=%...
0
votes
2answers
647 views

Getting value from file using Windows Batch scripting

Using Windows Batch scripting, I want to get the max_volume value (-2.9 in the following example) from a ffmpeg output written to a log file: [Parsed_volumedetect_0 @ 0000000005428b20] n_samples: ...
1
vote
1answer
664 views

What is the difference between regular and literal expressions in FINDSTR?

What is the difference between /R and /C? FINDSTR [options] [/F:file] [/C:string] [/G:file] [/D:DirList] [/A:color] [/OFF[LINE]] [string(s)] [pathname(s)] /C:string Use string as a literal ...
1
vote
1answer
6k views

Script to Find Certain words and delete those lines in a file

EDITED THE QUESTION as i am open to different type of solutions unlike just batch previously I am on Windows & some suggested SED etc. So i am OK with these 3rd party standalone exe's using ...
2
votes
3answers
4k views

In windows, is there a way to count the amount of times a string appears in a file

I am currently trying to write a batch script and at this point, I need to find a string, "null", and determine how many times it is shown in the file. I'm downloading an API from a website every-...
1
vote
1answer
1k views

Dir and Findstr commands taking a long time to complete in Batch File

dir %DRIVE_NAME%: /S /C /A-D /Q /T:C | findstr ".zip$ .doc$ .xls$ .xpt$ .cpt$ .cpo$ .xlsx$ .pdf$ .dat$ .txt$ .docx$ .csv$" >> file.info I am using above command to list all information in file, ...
2
votes
2answers
7k views

Use Batch findstr for files with whitespaces

I'm trying to search for a string in a given file. This file can have whitespaces in its name and I'm having trouble with the Batch file. I can easily do this by console getting the correct results: ...