Solved

DIR search not traversing properly

Posted on 2011-02-24
5
255 Views
Last Modified: 2012-06-22
Maybe I'm old-school, but I do a good bit of searching with the classic DIR /A/B/S, but today it doesn't seem to be working right.

Specifically, there was a folder on our server at U:\shared\elementary that is gone. Before I go pulling backups, I'd like to see if someone has (accidentally?) moved it. This:
U:\shared>dir /s/a/b elementary. 

Open in new window

shows a folder in a subdir called "elementary," but it's not the one I'm looking for. Next stop is running the same command at the root, but since there's another folder named "elementary" in the root (also not the right one,) the list is huge. So I try to slim it down with:
U:\>dir /s/a/b elementary. | find /v /i "u:\elementary"

Open in new window

But that gives me ZERO results, when I know good and well that there's a folder named "elementary" in a subdir of "shared." Running the command on the root with the find pipe omitted
(and outputting to a logfile) doesn't show the one I know about either. So obviously I can't trust these results!

Any idea what's going on here?
0
Comment
Question by:LSDIT
  • 2
  • 2
5 Comments
 
LVL 51

Accepted Solution

by:
Bill Prew earned 500 total points
ID: 34970914
I would think you want DIR /AD rather than just DIR /A, but I don't think that will resolve the problem.

Your command looks reasonable in general, although I wouldn't put the period after the directory name.

If you use Windows GUI tools to search for that folder, does it find it?  If not, then maybe it's a permissions issue?

~bp
0
 

Assisted Solution

by:LSDIT
LSDIT earned 0 total points
ID: 34971300
I don't know about the gui... using XP's silly search dog does a search for *elementary* and I don't know how to disable that.

And yeah, I'm used to using the dot to distinguish folders, but I suppose /ad is better. DIR /A without specified attributes lists files with any attributes, I believe.

I really can't see it being a rights issue, seeing as how I'm running the "search" as the same user (who is, incidentally, a domain admin) both times.

AHA!!

I figured it out. All the switches were stopping me from seeing the base command, which is "DIR ELEMENTARY". Of course, if there is a folder NAMED "elementary" in the current dir, it will list the contents of THAT folder, so it was running the command on THAT folder.

This works, forcing a search:
U:>dir /s/b/ad elementar?

Open in new window


Thanks for the help!
0
 
LVL 51

Expert Comment

by:Bill Prew
ID: 34976034
Welcome, glad my comment was of some use, thanks.

~bp
0
 
LVL 38

Expert Comment

by:BillDL
ID: 34977695
I know the question is in the process of being closed, so this is just for additional info and I am NOT seeking to squeeze into any points split.

I sometimes use the WHERE.EXE (version 5.0.1774.1) command line program from an earlier version of Windows on my XP system.  If you have an old Win98se CD lying around, look in the folder:
CD:\tools\reskit\file\
for where.exe and copy it to your C:\Windows or C:\Windows\System32 folder, first making sure that there isn't already a program of that name in either of those folders.  I don't think I would be allowed to attach a copy of it here for you.  It would be interesting to see if you find it to be a useful tool.

I generally use it with wildcards and redirect output to a text file for use in some other process or to examine for a particular purpose.  Here are all the switches:

WHERE [/r dir] [/qte] pattern ...

/r - recurse starting with directory dir
/q - quiet, use exit code (note lowercase q)
/t - times, display size and time
/e - .EXE, display .EXE type
/Q - double quote the output (note uppercase Q)

Examples:

WHERE notepad.exe                 Find ALL notepad.exe along the path
WHERE $windir:notepad.exe    Find ALL notepad.exe along %windir%
WHERE /r \ notepad.exe           Find ALL notepad.exe on current drive
WHERE /r . notepad.exe           Find ALL notepad.exe recursing on current directory
WHERE /r c:\windows\system notepad.exe   Find ALL notepad.exe recursing on c:\windows\system

Wildcards, * ?, allowed in bar in all of above

Note: if spaces are present in path or file names searched for, double-quote the path or filename in your command.
0
 

Author Closing Comment

by:LSDIT
ID: 35005236
Figured it out myself, but his comment helped me to do that.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now