Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Exclude FIles in DIR command

2,838 views
Skip to first unread message

Hank

unread,
Feb 3, 2009, 12:46:42 PM2/3/09
to
I have a need to search for specific files in an application's temp
folder that have random names like HotFixxxx.log, Patchxxx.log, and
NewestModule.log. Unfortnately, this same folder contains the app's
temp log files used for debugging and troubleshooting. Filenames like
rplib.log, ms.log, etc.

I want to exclude the debug/troubleshooting log files in my directory
search, but am having a hard time with that using the DIR command.
Here's the closest thing I could come up with, but obviously I can't
figure out how to add multiple exclude files here:

dir /b/s | find /v /i "rplib.log"

Any other suggestions are appreciated!

Hank

Matthias Tacke

unread,
Feb 3, 2009, 1:11:43 PM2/3/09
to

Use findstr instead of find.

dir /b/s | findstr /v /i "rplib\.log$ ms\.log$"

Findstr uses regex syntax by default and allows multiple keys separated
with spaces.

The regex syntax forces escaping of dots dollar and ^ (which are special
chars) with a leading backslash.

The ^ anchors a key at line begin, a dollar sign at the end.

The search strings may also be feed from a file (one key per line) with
the /G:filename.ext option.

For more info enter in cmd window:
findstr /?
or for the more detailed windows help
HH ntcmds.chm::/findstr.htm

--
HTH
Matthias

Hank

unread,
Feb 3, 2009, 4:39:53 PM2/3/09
to
On Feb 3, 11:11 am, Matthias Tacke <Matth...@Tacke.de> wrote:
> Use findstr instead of find.
>
> dir /b/s | findstr /v /i "rplib\.log$ ms\.log$"
>


Thanks for the help. One more question. There's some filenames that
look like this:

ccmtrace.log
ccmtrace.log.back
ccmrdk.log
ccmblk.log

I've tried regex using ccm.$, ccm*$, ccm$, but obviously I'm not
getting it. I've looked at some regex tutorials, but they're not
helping much.

Thanks
Hank

Rugxulo

unread,
Feb 3, 2009, 6:43:37 PM2/3/09
to
Hi,

On Feb 3, 11:46 am, Hank <hammerin.hanks...@gmail.com> wrote:
>
> I have a need to search for specific files in an application's temp
> folder that have random names like HotFixxxx.log, Patchxxx.log, and
> NewestModule.log.  Unfortnately, this same folder contains the app's
> temp log files used for debugging and troubleshooting.  Filenames like
> rplib.log, ms.log, etc.
>
> I want to exclude the debug/troubleshooting log files in my directory
> search, but am having a hard time with that using the DIR command.

Try 1DIR: (e.g., "1dir /!*.lzh,*.arj,*.zip,*.7z")

http://ourworld.compuserve.com/homepages/rproft/

Matthias Tacke

unread,
Feb 3, 2009, 8:58:04 PM2/3/09
to
The dot is for any char, the asterisk for any number of the previous,
so .* matches any number of any char

ccm.*$

should do, but take care the .* is greedy, if ccm appears somewhere
in the path like soccmatch\xyz.log this would match also.

--
HTH
Matthias

Hank

unread,
Feb 5, 2009, 10:42:25 AM2/5/09
to
On Feb 3, 6:58 pm, Matthias Tacke <Matth...@Tacke.de> wrote:
> The dot is for any char, the asterisk for any number of the previous,
> so .* matches any number of any char
>
> ccm.*$
>
> should do, but take care the .* is greedy, if ccm appears somewhere
> in the path like  soccmatch\xyz.log this would match also.
>
> --
> HTH
> Matthias- Hide quoted text -
>
> - Show quoted text -


Got it! Thanks Matthias!

Hank

0 new messages