Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Using the Windows CLI (cmd), how does one locate a file that he knows part of the name of? For instance, every single Windows workstation installs javac in a different location, how would one find it from the Windows CLI (cmd)?

Googling I see mention only of using the Windows Explorer (file manager) GUI or downloading some freeware application. Does Windows really not have a locate command built in? Do the server editions have it? I do not want to install cygwin or anything else, these are typically not my machines.


share|improve this question
Nothing built-in to the Windows command-line is really similar to locate. I would recommend locate32 ( locate32.net ) –  John T Aug 23 '11 at 19:58
javac should usually be at the same place... –  Tom Wijsman Aug 23 '11 at 21:47

7 Answers 7

up vote 11 down vote accepted

You should be able to do what you need to do with dir:

dir [filename] /s

Replace [filename] with the filename you're looking for, you should be able to use wildcards. /s makes it search sub-directories so if you need to you can start in the root of C: and have it check the entire drive.

share|improve this answer
If you're searching the entire drive for a common file name it may also pay to include /p to that it only presents you with a page of results at a time. –  Windos Aug 23 '11 at 19:41
Thank you, this looks perfect. I do often know at least that I need to search in C:\WINDOWS so this could narrow down the time that the search takes. –  dotancohen Aug 23 '11 at 20:41
I don't think that javac is installed to C:\WINDOWS... –  Tom Wijsman Aug 23 '11 at 21:47

Windos has the most straightforward answer. But if you're fond of the command line, you may want to look at powershell too. To accomplish the same type of search you'd use

get-childitem [starting path eg c:\users\] -filter [wildcarded search or filename] -recurse

Which has the nice side benefit of being able to be pumped into a handy foreach statement and run a process against the search results.

get-childitem [starting path eg c:\users\] -filter [wildcarded search or filename] -recurse |
    foreach ($_){
          [do something to $_.fullname , like maybe display my image file or relocate it etc..]
share|improve this answer
This feels too long to type out. –  Tom Wijsman Aug 23 '11 at 21:48
Get-ChildItem can be abbreviated as gci or ls. –  digitxp Aug 23 '11 at 22:19

I simply got a locate program for Windows. You just need to follow the read me instructions and copy the .dll files and .exe to system32.

Alternative includes adding the program path to the environment variable PATH.

The idea is to get locate on Windows if you're looking for something "like" locate. :)

share|improve this answer
Thank you Cheeku, that looks like a handy application. However I did mention that I cannot install applications on the system as they are typically not my systems. –  dotancohen Dec 23 '13 at 8:36
Yes, but I answered anyways becasue other people like me can find it useful and others won't be confused since this post already has an accepted answer! –  Cheeku Dec 23 '13 at 17:37
locate is on my Win7 computer. It complains about the database being 435 days old, when the intallation is not more than 3 months old. And updatedb is not included. –  vinnief Jan 16 '14 at 14:46
@vinnief That's a particular problem with your installation, I presume. –  Cheeku Jan 16 '14 at 23:28
@Cheeku - This is the same app pointed at by John T. It is not CLI as the OP asked, but it is awesome. –  sancho.s Nov 6 '14 at 14:05

The question is somewhat ambiguous.

You want to locate a file (stated in the body of the OP), but you also want a "locate-type" command/app (stated in the title). There is one subtle consideration with huge implications. You can locate with two different methods:

  1. Searching the target tree structure directly in each search (slow).

  2. First creating a database of the target tree structure (may be time-consuming), and then locating by searching the database (very fast). The database has to be updated periodically to obtain good results in searches. See http://en.wikipedia.org/wiki/Locate_%28Unix%29.

Unix locate is of "type 2", but as per the body of your OP, you would be ok with any of the two methods. Moreover, you ask specifically about CLI options.

I list below some options, and I specify whether they are CLI / GUI, type 1 / 2, and I add some comments.

  1. http://locate32.cogit.net/ (already pointed at by John T and then by Cheeku). GUI, type 2. There is a portable version. Outstanding easiness of use, and configurability. Very similar to Unix locate (which I used and liked a lot).
    Note: Being used to Unix's Updatedb taking quite long to update a database (of course, it depends on the size of the scanned tree), I find locate32 extremely fast. I do not know how it can be so much improved.

  2. http://sourceforge.net/projects/winlocate/ CLI, type 2.

  3. dir [filename] /s, the solution by Windos. CLI, type 1.

  4. gci ..., the solution by OldWolf. CLI, type 1.

  5. http://gnuwin32.sourceforge.net/packages/findutils.htm CLI, type 2.

  6. Everything GUI, type ?.

share|improve this answer
Thank you, this is a good explanation and a nice summary of options. –  dotancohen Nov 6 '14 at 14:35

I created a PowerShell port for locate and updatedb. Uses SQLite as a backend, and has an auto installer. Just

.\Invoke-Locate.ps1 -install. 

locates take about 300ms/query.


locate whatever

and you're set.

enter image description here


share|improve this answer

No need to install by hand. See http://chocolatey.org

choco install winlocate

Restart shell environment

Updatedb.bat -a
Locate.bat somefile
share|improve this answer

I'm not aware of any CLI method to do this in Windows. Keep in mind that the Windows CLI has been abandoned by common users, so it offers a generally less mature set of tools. Your best bet might be using the gnu find in Windows, which you can get from GnuWin32. If you're developing a script, you'd just have to include find.exe and its dependencies with the script (don't worry, it's not very big).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.