[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 264
  • Last Modified:

DIR search not traversing properly

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
LSDIT
Asked:
LSDIT
  • 2
  • 2
2 Solutions
 
Bill PrewCommented:
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
 
LSDITAuthor Commented:
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
 
Bill PrewCommented:
Welcome, glad my comment was of some use, thanks.

~bp
0
 
BillDLCommented:
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
 
LSDITAuthor Commented:
Figured it out myself, but his comment helped me to do that.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now