FAQ Database Discussion Community


Batch: find files with specific content and extend existing name

batch-file,rename,findstr
I have about 100 .xml files, but its filenames are not self-explanatory. Therefore I would like to look for a specific word and extend the respecting file with this word. Thanks to some other helpful entries, I could partially figure out how to do this, but somehow the files are...

Search for text1 AND text2 in a line of file.txt

batch-file,cmd,find,findstr
I am trying to return results only for lines that contain matching text via cmd. In this case the line must match in both "Name" and "Surname". Read though http://ss64.com/nt/findstr.html, and tried the first example findstr "James Henry" sam.txt >sam2.txt Unfortunately, this also returns all lines that contain just James...

How do I make findstr show the full file path inline?

command-line,path,grep,dos,findstr
When I use grep I get a list of matching results with the full file path for all the child subdirectories. When i do this with findstr - I don't get the inline results. My question is: How do I make findstr show the full file path inline?...

FINDSTR RegEx assistance?

regex,findstr
I'm processing the output from an SVNLOOK command. All the lines returned start with A, U or D. I need to find all the rows that do NOT start with "D". What's the Regex pattern for this? I tried ^[^D] (starting with, not "D") but that doesn't work. If you...

findstr displays matches in one line

windows,batch-file,findstr
I have two files: 1.txt: abc def 2.txt: abc Please note that 2.txt contains only 3 characters, no empty lines. Now if I do: findstr /S /I /L /A:02 "abc" * I get this result: 1.txt:abc 2.txt:abc Which is what I expect. However after renaming 1.txt to uno.txt and 2.txt...

As only show the words found in the findstr

batch-file,findstr
How do I display only the words found in the search instead of displaying the lines? My code: Findstr /li /G:"List.txt" "File.txt">"Result.TxT" List: Disc Music Song Album Result: DISC1312we7das67da 13dsdsa67dsahdsa7aMUSIC dsadsdfdsaSONG1223234235 The desired result: Disc Music Song ...

Find string which include “%” with findstr

windows,batch-file,findstr
Im making a bat-file for windows that will run a simulation. It will then look at the result in the console and search for the string "win%". Ftm I can find anything including win but that gives me alot of unnessesary data. This is what I got now: command |...

How to show the place and only the words found Findstr?

batch-file,findstr
I wonder how do I show the location where the words were found in findstr? My Code: Set "LFiles=%temp%\Files\*.txt">nul 2>&1 Findstr /li /G:"List.txt" "%LFiles%">"Result.TxT" (for /F %%a in (List.txt) do ( Findstr /li /C:"%%a" "%LFiles%" > NUL if not errorlevel 1 echo %%a ))>"Result2.TxT" List: Disc Music Song Album Result:...