findstr

findstr or grep that autodetects chararacter encoding (UTF-16)

I want to do this: findstr /s /c:some-symbol * or the grep equivalent grep -R some-symbol * but I need the utility to autodetect files encoded in UTF-16 (and friends) and search them appropriately. My files even have the byte-ordering mark FFEE in them so I'm not even looking for heroic autodetection. Any suggestions? Thanks,...

SVN Pre Commit Hooks

I am currently trying to extend our already existing (and working) pre commit batch file for committing to SVN. The first part blocks any commit that does not have comments and works as expected. The second part is an attmept to block users committing SUO files, however this is currently blocking all commits. My understanding of DOs sc...

Escaping a backslash in Batch File using FINDSTR

In my svn Pre commit hooks I use findstr to block certain file types beign committed. I now want to extend this to directories, in the first instance \obj\ directories however I am having problems with the Regular expression and escaping the \ of the dir Currently I have "C:\Program Files\VisualSVN Server\bin\svnlook.exe" changed -t ...

How do I redirect output into Gvim as a list of files to be opened?

I would like findstr /m background *.vim | gvim to open all *.vim files containing background in a single instance of gvim - but I can't get the piping to work. This is very similar to this question but instead of capturing the stdin output I would like GViM to treat the output as a list of files to be opened - and on a dos system so x...

[Batch] write results into a text file

I created a batch that will use windows FINDSTR to search for my selective input. I am trying to log my results of my search term in a text file called results.txt So I do have something like this so results are kept not overwritten: >>Results.txt I've created the txt file so it'll write to it, this is what I tried and won't work: ...

Regular expressions in findstr

I'm doing a little string validation with findstr and its /r flag to allow for regular expressions. In particular I'd like to validate integers. The regex ^[0-9][0-9]*$ worked fine for non-negative numbers but since I now support negative numbers as well I tried ^([1-9][0-9]*|0|-[1-9][0-9]*)$ for either positive or negative intege...

Why does findstr not handle case properly (in some circumstances)?

While writing some recent scripts in cmd.exe, I had a need to use findstr with regular expressions - customer required standard cmd.exe commands (no GnuWin32 nor Cygwin nor VBS nor Powershell). I just wanted to know if a variable contained any upper-case characters and attempted to use: > set myvar=abc > echo %myvar%|findstr /r "[A-Z]"...

piping findstr's output

Windows command line, I want to search a file for all rows starting with: # NNN "<file>.inc" where NNN is a number and <file> any string. I want to use findstr, because I cannot require that the users of the script install ack. Here is the expression I came up with: >findstr /r /c:"^# [0-9][0-9]* \"[a-zA-Z0-9_]*.inc" all_pre.txt ...

Using Sleep with findstr in a .bat

I created a .bat file with the below lines cd C:\MyFolder d: findstr "Apple" C:\log.txt |findstr "red" > red_apples.txt SLEEP 3600 GOTO START When the bat is executed, the SLEEP is not working and the commands are running continously. Is there anything wrong with the code? Please help ! ...

findstr regex search

I need to retrieve some value based on regular expression using findstr but findstr returns the whole line. Is there any way to change it? ...

Piping to findstr's input

I have a text file with a list of macro names (one per line). My final goal is to get a print of how many times the macro's name appears in the files of the current directory. The macro's names are in C:\temp\macros.txt. type C:\temp\macros.txt in the command prompt prints the list alright. Now I want to pipe that output to the standa...

grep in gvim always returns E40: Can't open errorfile

I am using gvim grep that defaults to findstr in a Windows XP environment. The gvim has access to the folder where the error file is to be opened, but it fails. Is there anyway to change where the error file goes? Do you have any other tips/suggestions for using findstr in gvim for windows? ...

DOS Command FindStr

Hi, I have a need to use the DOS command FINDSTR to search in all our source code files mixed with other types of files such as PDF, exe, dll, etc. I do not need to search those binary files. Is there a way to exclude binary files? My command looks like findstr /r /n /o /s /g:c:\projects\vsssearch\muafinddata.txt /d:c:/projects/axl *...