5
0
I was just trying to check a dump-directory for any ZIP programs like PeaZip, NanoZip, etc. and ran into an odd problem that I have seen only a few times before.
I used the following command to list files whose filenames contain zip
(e.g., nanozip.zip
, peazip2.rar
, winzip-beta.exe
, etc.):
dir *zip*
This listed any files whose filenames contain zip
, but also all files with a .zip
extension (e.g., foobar.zip
).
I then tried the following:
dir *zip*.*
This gave the same results.
Does anyone know of a way to get the expected results? (I know that for
may be able to do it, but the output won’t be correct.)
You said you're looking for any programs with
zip
in the name. If that's the case and I haven't misunderstood your objective, why isn't it sufficient to do the obvious and just add the.exe
extension to your pattern, e.g.,dir *zip*.exe
. – Nicole Hamilton – 2012-12-03T17:40:25.247Yes, I was looking for programs when I ran into this scenario, but not all programs are executable. My example clearly showed that the files could be
.rar
,.zip
,.exe
, etc. hence the title and question specifically asking about files. – Synetech – 2012-12-03T17:41:17.413AFAIK the cmd.exe pattern matching simply won't support what you want. It isn't that great. – Zoredache – 2012-12-03T17:42:22.760
Okay, so are you looking for any names that contain
zip
except in the extension? – Nicole Hamilton – 2012-12-03T17:42:51.970@Zoredache, it is a strange shortcoming. ☹ – Synetech – 2012-12-03T17:42:57.483
@NicoleHamilton, no, they can have
zip
(in this case) in the extension as well, so long as they have it in the filename. Look at the samples I gave. – Synetech – 2012-12-03T17:43:33.917I think I understood but poorly phrased. Let me try again: You want names that contain
zip
except when the only place wherezip
appears is in the extension? – Nicole Hamilton – 2012-12-03T17:47:43.123@NicoleHamilton, yes, that’s correct. Conversely, any files that have
zip
in the filename regardless of the extension. (Of course this goes for any sub string that may show up in an extension. For example, finding filenames that containart
in a directory that has.part
files, etc.) – Synetech – 2012-12-03T17:57:36.087Sorry. I was confused by your use of the terms program and filename. I usually think of programs as executables and a filename as including the extension in the context in which I mistook your question. – Nicole Hamilton – 2012-12-03T18:12:29.183