Find files NOT matching *_abc.* - filter

In dos, when I wanted to get a list of files matching a specific filter, I could use something along the lines of:
*.* - Means return everything
*.txt - Means return all files with a .txt extension
*_abc.* - Means return every file that ends with _abc
My question is, using that dos filter structure, how could I return all files NOT matching *_abc.* (In other words, return all files whos name does NOT end in _abc)?
I don't remember if this is possible and I need this since a company I'm working with is using a very old program that still uses that form of command filtering for selecting files for the program to work on - Also, unfortunately, I can't do it via a batch command... It has to be a single command line statement.
Thanks!!!

Pipe the results of your listing to FINDSTR with an appropriate regex search string and the /V option to filter out matching lines.
dir /b /a-d * | findstr /v /r "_abc\.[^.]*$"

Take a look at this answer to a sort of unrelated question. The answer does show though how to do a REGEX search on file names, and of course if you use a REGEX you can easily search for things that don't match the expression.
https://stackoverflow.com/a/7381962/1246574
Hope that helps.
EDIT
Sorry, didn't see you needed it to be a single line statement and not a batch. I'll leave the above answer though in case it helps anyone else, and I'll also see if I can look up how to do it in a single statement.

Related

File types search pattern in VS find

In the visual studio 2015 find and replace window you can specify file types to look in for:
Looking in *.cs-Files
There, you can enter sth like *.cs which searches in i.e. Program.cs and Class1.cs.
*.as?x searches in Program.asPx and Program.asCx.
I've found no other way to enter a pattern except the wildcard characters *(any item 0 to infinit times) and ?(any item one time).
Is it possible to use any other pattern here to search in cs and resx-files, i.e. *.(resx|cs)[this doesnt work]? Is it possible to use some kind of regex like in the Find what-field?
In Find what you may use the regex defined here.
You can enter a semicolon-separated list of patterns, like this: *.resx;*.cs

Concatenating files with windows copy /b: does not work for overwriting?

I'm trying to concatenate two binary files in Windows. The second of the two files is very large so I would like to avoid making a new file that is the concatenation of the two - instead, I would like the concatenation to appear in place, overwriting the larger file (hopefully this can also be faster?).
I tried the following:
copy /b mysmallfile.dat + mybigfile.dat mybigfile.dat
It asks if I want to overwrite mybigfile.dat, and when I say yes, mybigfile.dat now only contains the contents of mysmallfile.dat, rather than the concatenation of the two.
Very confusingly, if I try:
copy /b mybigfile.dat + mysmallfile.dat mybigfile.dat
It does not ask about overwriting, but does produce a file that is the concatenation of the two! However, the order is incorrect, I need the small file to be first in the concatenation.
I can't understand this behavior or how to get it to work. Any ideas? Thanks!

Findstr does not return second line

I am using FINDSTR -I to find a string in n number of files in a folder. Also write the results to a new file.
I need find string "IDC" along with number next to it in all files.
but on some lines in files, IDC is spread across two lines, and my search returns just first line.
09:49:34.386 4;**IDC-200.0**;CA
13:07:39.987 87;T22.8,BT2;LI;VLT12.7;**IDC-**
13:07:39.995 **42.0**;CAP240.0/
can some one help in copy next line to output file, if IDC is spread across two lines.
Microsoft’s findstr works strictly line based. It is not really possible to search for a string which does not completely exist within a line and get all lines output.
But it is possible to define multiple search strings which are used one after the other on a line before processing next line until either one of the search strings returns a positive match or none of the search strings matches a string on current line.
Example:
%SystemRoot%\System32\findstr.exe /R /C:"IDC-" /C:"^[0-2][0-9]:[0-5][0-9]:[0-5][0-9]\.[0-9][0-9][0-9] \*\*[0-9][0-9.]*\*\*;" *.txt
Findstr (SS64 article) searches with those options in all *.txt files of current folder for
a line containing case sensitive the string IDC- anywhere within the line or
a line starting with time in expected format, a space, two asterisks, a floating point number with at least 1 digit before decimal point, two more asterisks and a semicolon.
With those two search strings all 3 lines of provided example are found and output in correct order and other lines not containing IDC- or matching the second regular expression search string are ignored by FINDSTR.
Note: SS64 article FINDSTR - Searching across Line Breaks explains how a search can be done which includes a line break. But output is nevertheless only the first line on which the found multi-line string begins.

findstr search string not working

I have a question regarding findstr which I hope someone can assist with.
I would like to perform a search piped from "net user" which can search for number of strings in the output. Those strings can be specific words or and specific phase.
Specific words are not a problem and works a treat but when combined with a specific phase the results are not as expected.
Below is a extract of the command which is pulling a variable from a for loop (%%a).
2>NUL net user /domain "%%a" | FINDSTR /I /C:"2221" /C:"deprovisioned" /C:"disabled" /C:"Account active No"
FINDSTR /I "2221" "deprovisioned" "disabled" works no problem.
But I need a 4th string added at the end which unfortunately contains lots spaces.
When added the 4th search string it's simply missed from the search results.
Can anyone provide any advice?
I've converted to Powershell and problem solved.
Thank you for your input.
skothk

Bug in Windows's FindFirstFile() function?

Why does calling FindFirstFile with the pattern *.* match a name like Windows?
Edit: I guess I can also guess what's happening, but is there any documentation on the reason as well?
In the blog post 'How did wildcards work in MS-DOS?' Raymond Chen describes how the original DOS wildcard matching was implemented. At the end of the post he points out how *.* is handled as a special case in the Win32 wildcard matching algorithm.
A quote from the post
For example, if your pattern ends in .*, the .* is ignored. Without this rule, the pattern *.* would match only files that contained a dot, which would break probably 90% of all the batch files on the planet, as well as everybody's muscle memory, since everybody running Windows NT 3.1 grew up in a world where *.* meant all files.
*.* matches everything in the target directory.
This is because *. matches up to the final period; if there is no period in the name then that name is treated as if it ended in a period; so *. matches only names beginning with a period and names containing no period (.afile / adirname) if you add a * on the end for *.* then it also matches beyond the final period so includes file names containing a period, this covers all possible file names.

Resources