Categories
Interior

How to use find from the windows command prompt

Martin Hendrikx has been writing about technology for years. His freelance career includes everything from blog posts and news articles to eBooks and academic papers. Read more.

How to use find from the windows command prompt

Find is another great command line tool that every Windows user should know about because it can be used to search content of files for specific strings of text.

Find’s Switches and Parameters

As with every command prompt based tool in Windows, there are certain switches and parameters you will need to know in order to use the tools effectively. These are listed and explained below.

  1. /v – This switch will show any lines that don’t contain the string of words you specified.
  2. /c – This switch tells the find tool to count how many lines contain your search terms.
  3. /n – This switch shows the numbers that correspond with the lines.
  4. /i – This switch tells find to ignore the case of text you are searching for.

In addition to these switches, there are two parameters which you can specify with this tool.

  1. “String” – The string will be the words you are searching for in your documents. You must always remember to keep this secrtion surrounded by quotation marks, otherwise your command will return an error.
  2. Pathname – This parameter is where you will specify the location that you want to search. This can be as broad as listing a drive or as specific as defining a single or multiple files. If you don’t specify a path, FIND will ask you for text input or may accept text piped from another command. When you are ready to end the manual text input, you can press “Ctrl + Z.” We will discuss this more later.

Find’s Syntax

Like every tool in windows, you will need to know how to enter your commands. The syntax below is the perfect model.

Depending on your command, you will receive one of three %errorlevel% responses.

  1. 0 – The string you were searching for was found.
  2. 1 – The string you were searching for was not found.
  3. 2 – This means you had a bad switch or your parameters were incorrect.

Let’s Practice

Before we get started, you should download our three sample text documents which we will use for the test.

These documents each contain a paragraph of text with a few similar word groupings. Once you have downloaded these three documents, you can copy them into any folder on your computer. For the purposes of this tutorial, we will put all three text documents on the desktop.

Now you will need to open up an elevated command prompt window. Open the start menu in Windows 7 and 10 or open the search function in Windows 8 and search for CMD. Next, right-click on it and then press “Run as administrator.” While you don’t need to open an elevated command prompt window, it will help you to avoid any pesky confirmation dialog boxes.

How to use find from the windows command prompt

Our tutorial today will cover several simple scenarios which will be elaborated on below.

  1. Search a single document for a string of words.
  2. Search multiple documents for the same string of words.
  3. Count the number of lines in a file or multiple files.

Scenario 1 – Search a single document for a string of words.

Now that you have your three documents downloaded, we will enter a command to search the text file called “exercise” for the words “martin hendrikx.” Use the command shown below. Remember to put your search string in quotation marks and change the path to match the folder where your documents are saved.

You will notice that no results showed up. Don’t worry, you did nothing wrong. The reason you have no results is because FIND is looking for an exact match to your search string. Let’s try it again, but this time, let’s add the “/i” switch so that FIND ignores the case of your search string.

How to use find from the windows command prompt

Now you can see that FIND brought up one line that matches the search string, which means it is working. Let’s try this again, but change the search string to “sushi”; if your results look like the image below, you did it right.

Scenario 2 – Search multiple documents for the same string of words.

Now that you know how to do a basic search, let’s try to widen the span of the search. We will now search two of the text files (exercise and sample) for the term “sushi.” Do this by entering the following string. Remember to change the path to match the location of your files and add the “/i” switch so that your search is not case-sensitive.

How to use find from the windows command prompt

You will notice that the search terms were found in both documents and the sentences in which they were found, are listed under their corresponding file names and locations. Try this again, but this time, add the third file to the FIND command and search for the word “potato” instead. Your search results should look like the image below.

How to use find from the windows command prompt

Note that the text found in each document is actually “potatoes” which means that even if you type a part of a word, you will see any phrases that contain the search string. Alternatively, you could use this command to check all text files.

Scenario 3 – Count the number of lines in a file.

If you want to know how many lines there are in a file, you can use the search command below. Remember to add a space between all your switches. In this case, we will replace the pathname with that of the “sample.txt” file. If you want only a number as your result, use this command:

If you want the number and the file info, use this command:

If you want to count the lines in multiple files on the desktop, use the following command.

How to use find from the windows command prompt

You can now experiment with a few different commands and familiarize yourself with the tool. It can help to save a lot of time in the future once you have a system created. Have fun and keep on geeking.

Searches for a string of text in a file or files, and displays lines of text that contain the specified string.

Syntax

Parameters

Parameter Description
/v Displays all lines that don’t contain the specified .
/c Counts the lines that contain the specified and displays the total.
/n Precedes each line with the file’s line number.
/i Specifies that the search is not case-sensitive.
[/off[line]] Doesn’t skip files that have the offline attribute set.
Required. Specifies the group of characters (enclosed in quotation marks) that you want to search for.
[ :][

Exit codes

Exit code Description
0 The searched string was found
1 Searched string not found
2 Searched file not found or invalid command line switch was given

Remarks

If you don’t use /i, this command searches for exactly what you specify for string. For example, this command treats the characters a and A differently. If you use /i, however, the search becomes case insensitive, and it treats a and A as the same character.

If the string you want to search for contains quotation marks, you must use double quotation marks for each quotation mark contained within the string (for example, “””This string contains quotation marks”””).

If you omit a file name, this command acts as a filter, taking input from the standard input source (usually the keyboard, a pipe (|), or a redirected file) and then displays any lines that contain string.

To exit the console search use CTRL-X or CTRL-z .

You can type parameters and command-line options for the find command in any order.

You can’t use wildcards (* and ?) in the searched string. To search for a string with wild cards and regex patterns, you can use the FINDSTR command.

If you use /c and /v in the same command line, this command displays a count of the lines that don’t contain the specified string. If you specify /c and /n in the same command line, find ignores /n.

This command doesn’t recognize carriage returns. When you use this command to search for text in a file that includes carriage returns, you must limit the search string to text that can be found between carriage returns (that is, a string that is not likely to be interrupted by a carriage return). For example, this command doesn’t report a match for the string tax file if a carriage return occurs between the words tax and file.

The command accepts wildcards for file names. When searching in file (or files) it will print the file of the processed file predeceased by ten dashes.

Find command cannot read alternate data streams. For searching in alternate data streams use findstr, more or for /f commands.

Examples

To display all lines from pencil.md that contain the string pencil sharpener, type:

To find the text, “The scientists labeled their paper for discussion only. It is not a final report.” (including the quotes) in the report.txt file, type:

To search for a set of files, you can use wildcards. To search the current directory for files that have the extension .bat and that contain the string PROMPT ignoring the case, type:

To find files names in a directory that contain the string CPU, use the pipe (|) to direct the output of the dir command to the find command as follows:

Find all running processes that do NOT contain agent:

Marshall Gunnell is a writer with experience in the data storage industry. He worked at Synology, and most recently as CMO and technical staff writer at StorageReview. He’s currently an API/Software Technical Writer at LINE Corporation in Tokyo, Japan, runs ITEnterpriser, a data-storage and cybersecurity-focused online media, and plays with development, with his RAID calculator being his first public project. Read more.

How to use find from the windows command prompt

Once you’ve learned how to navigate directories on Windows 10, the next step is learning how to find and open files using the Command Prompt. It’s just as easy as navigating through and opening a file in File Explorer. Here’s how it’s done.

First, open the Command Prompt on your PC by typing “cmd” in the Windows Search bar and then selecting “Command Prompt” from the search results.

How to use find from the windows command prompt

With the Command Prompt opened, you’re ready to find and open your file.

Find Files Using Command Prompt

Maybe you already know the file path to the item you want to open–maybe not. If not, you don’t need to search through File Explorer just to come back to the Command Prompt later. You can use this command instead:

dir “\search term*” /s

Just replace “search term” with, of course, the actual search term. So, if we wanted to locate our file called “Example File,” we’d use this command:

dir “\example file*” /s

Command Prompt will now search and find all instances of the search term you entered. It will (1) show you the file path, and (2) give you the file name and extension.

How to use find from the windows command prompt

Now that we’ve found our file, let’s open it.

Open Files Using Command Prompt

To open the file, you need to navigate to the directory in the Command Prompt that contains the file you would like to open. In this example, we’ve created an “Example” folder in our “Documents” folder, so we’ll head there.

In Command Prompt, use the Change Directories command ( cd ) to navigate through your folders. Because we’re currently at the top level of the computer’s file system, we’ll need to go to “Documents” first and then “Example.” So, we’ll use this command:

Note that you must navigate to the immediate file structure. In this case, we can’t skip “Documents” and jump straight to “Example.”

How to use find from the windows command prompt

Once you have inputted your command, press the Enter key. You’ll now be in that folder.

How to use find from the windows command prompt

It’s now time to open the file within that folder. Our file is named “Example File.”

To open the file, enter the file name and extension in quotations. In this case:

How to use find from the windows command prompt

The file will now open.

To make things a bit quicker, you can actually navigate to the correct folder and open the file in a single command. Assuming we are back at the top level, we would run this command:

How to use find from the windows command prompt

The only difference is you don’t add the cd command and the entire path is in quotations.

How to use find from the windows command prompt

Is Windows search too slow for you? Learn how to speed up your search using the find command in the Command Prompt window.

Windows has some built-in search capabilities, but they may not be to your liking. Cortana or the standard Search box on the Taskbar and the Search box in File Explorer in Windows 10 allow you to search through file contents, but they can be slow, especially the File Explorer search.

There’s a faster way to search the contents of files on your hard drive using the command line. The find command searches for text strings in files and returns the lines of text from the files in which the text string was found.

NOTE: The find command is not suitable for large files or large numbers of files.

Today we’ll cover how to use the find command and we’ll provide some examples.

Open the Command Prompt Window with Administrative Privileges

Opening the Command Prompt window as administrator is not necessary. However, it does help you avoid annoying confirmation dialog boxes. Just be careful what commands you run as administrator on the command line. Using the find command as administrator is safe as it doesn’t change or delete any files.

Enter cmd.exe in the Search box on the Taskbar. Then, right-click on the Command Prompt item under Best match and select Run as administrator from the popup menu.

How to use find from the windows command prompt

If the User Account Control dialog box displays, click Yes to continue.

NOTE: You may not see this dialog box, depending on your User Account Control settings. We don’t recommend disabling UAC entirely.

How to use find from the windows command prompt

Switches and Parameters for the find Command

Most commands have optional switches that modify the default operation of the command. You can get help to see all the available switches for the find command by typing the following line at the prompt and pressing Enter.

How to use find from the windows command prompt

The switches can be lowercase or uppercase.

For the “string” parameter, you must surround the string with double quotes, otherwise the find command will not work and will return an error.

The [drive:][path]filename parameter can be anything from a drive letter to a single file or multiple files.

Syntax for the find Command

A command’s syntax is a specific way to organize the command and its switches and parameters. The following is the general syntax for the find command.

The switches can be in any order as long as they’re before the “string” parameter. The brackets [] indicate that the switch or parameter is optional.

Search a Single Document for a Text String

First, we’ll show you how to search one document for all occurrences of a text string. The following command searches the example1.txt file for the phrase “groovypost is the best tech site”.

NOTE: If there are spaces in any part of the path or file name, you must put quotes around the entire path, like we did in the above command. The quotes are not really needed in this case, but it doesn’t hurt to have them.

How to use find from the windows command prompt

Notice that the phrase was not found in the above example (nothing is listed below the path to the file), even though it is in the file. That’s because the case in “groovypost” did not match what was in the file, which is “groovyPost”. Add the “/i” (lowercase or uppercase letter “i”) switch right after the find command (before the phrase) to ignore the case when looking for the text phrase.

Now, the phrase was found and the entire line containing the phrase prints to the screen below the path to the file being searched.

How to use find from the windows command prompt

Search Multiple Documents for the Same Text String

Now that you can search one file for a text string, let’s search multiple files for the same text string.

You can specify multiple files to search in the find command by putting the path to each file in quotes separated by a space.

You could also search all text files in a directory using the wildcard character, which is an asterisk (*), as shown in following command.

The search term was found in both documents and the sentences in which they were found are listed under the full path to each file.

How to use find from the windows command prompt

Count the Number of Lines in a File

If you want to know how many lines there are in a file, you can use a combination of the type and find commands. The type command displays the contents of one or more text files.

We piped the results of the type command into the find command using the vertical bar (|). We used the “/v” switch to display all lines NOT containing the “” string, so every line with text will be counted. To display only the number of lines in the text file (not the lines themselves), we use the “/c” switch.

How to use find from the windows command prompt

Send the Output of Another Command to the Find Command

You can also search all file names in a directory for a certain string by piping the output of the dir command to the find command.

For example, we got the directory listing of the C:\Users\Lori\Documents\FindCommandExamples directory and any subdirectories in that directory (“/s” switch). We also specified to use the bare format with no heading information or summary (“/b” switch) and to display the listing in the same format as the wide list format (“/w” switch) but sorted by column (“/d” switch).

Then, we pipe (|) the output of the dir command into the find command, only adding “example” as the parameter. We didn’t add any switches to the find command. The file names to search come from the output of the dir command.

How to use find from the windows command prompt

Do you prefer using the find command or the Search box in File Explorer? How have you used the find command? Share your ideas and examples with us in the comments below.

Marshall Gunnell is a writer with experience in the data storage industry. He worked at Synology, and most recently as CMO and technical staff writer at StorageReview. He’s currently an API/Software Technical Writer at LINE Corporation in Tokyo, Japan, runs ITEnterpriser, a data-storage and cybersecurity-focused online media, and plays with development, with his RAID calculator being his first public project. Read more.

If you’re looking for your Windows 10 product key, you can find it by entering a quick command in the Command Prompt. Here’s how—plus a neat little trick for finding the product key using a Windows Registry method.

Find Your Windows 10 Product Key Using the Command Prompt

To find your Windows 10 product key using the Command Prompt, you’ll need to open the command line application with administrative privileges. To do this, type “cmd” in the Windows search bar.

Command Prompt will appear in the search results. Right-click it and select “Run As Administrator” from the window that appears. If prompted, enter your Windows account password.

How to use find from the windows command prompt

Once open, copy and paste the following command and then hit the Enter key:

The 25-digit product key will then appear.

How to use find from the windows command prompt

Note: This method displays the Windows product key stored in your computer’s BIOS or UEFI firmware. In other words, it shows the original Windows key your computer came with. If you’ve installed Windows with a different key since then (or acquired a digital license), it will be different from the current key in use on your PC. If you want the current key in use on your PC, NirSoft’s ProduKey is a good graphical tool for finding it.

That’s all there is to it. This way is quick, but this isn’t likely a code you’ll remember very easily. If you’d like a faster way of accessing your product key in the future, you can use the Windows Registry method instead.

Find Your Windows 10 Product Key Using a Windows Registry Method

Update: This method is all over the web, but it doesn’t seem to return a real usable key on the latest version of Windows 10. (For example, this script in Microsoft’s TechNet gallery works differently, but also grabs output from “DigitalProductId” in the registry.) As of July 2020, we recommend you skip this section and use the above method instead.

The Windows Registry tip was initially posted by a user (whose account is no longer active) in the Microsoft forum.

First, open Notepad by right-clicking anywhere on the desktop, hovering over “New,” and then selecting “Text Document” from the menu.

How to use find from the windows command prompt

Copy and paste this code into Notepad:

Next, click the “File” tab and select “Save As.”

How to use find from the windows command prompt

In File Explorer, set the “Save As Type” dropdown to “All Files” and give your file a name. You can use any name, but it has to be a .vbs file. You can name it something like: productkey.vbs

How to use find from the windows command prompt

Once you’ve entered a file name, save the file.

You can now view your Windows 10 product key at any time by opening the new file.

Have you ever wondered who owns a particular domain name? Have you ever wanted to purchase a domain name and wanted to know if the domain was available?

Every domain name (e.g., techjunkie.com) is owned by a person, company, or organization. When the domain purchaser registers the domain name, they enter their contact information into a database called a database of Top Level Domains (TLD’s) such as .com, .net, and .org domains

However, many domain owners turn on privacy protection so that their contact information isn’t publically available. Most domain name registrars (usually hosting companies) offer privacy protection for a small fee.

In addition to using the Whois to look up domain name ownership, you can also look up the same sort of information about IP addresses, which would mostly be useful for system and network administrators

The official interface to the Whois Database is the ICANN Whois. Try looking up a domain name such as microsoft.com using the ICANN Whois and you’ll get output that looks like this:

How to use find from the windows command prompt

Surprise, microsoft.com is owned by the Microsoft Corporation. Note that there are three different types of contacts – the actual registrant, the administrative contact, and the technical contact. The Whois is a critical tool for many web developers, designers, IT consultants, and entrepreneurs.

Usually, when someone wants to look up a domain they use a web tool such as ICANN Whois or another free online interface to the Whois database. However, if you’re in a line of work, finding yourself making frequent Whois queries, you will want a more convenient and efficient method for making Whois queries. That’s where the whois utility available for Windows and built right into macOS and Linux systems.

Microsoft makes a Whois utility available as part of the Windows Sysinternals toolkit, a suite of tools for server and network administrators, and as a free stand-alone Whois utility that runs on Windows Client Vista and higher, Windows Server 2008 and higher, and on Nano Server 2016 and higher. Windows Whois is simple to download and use:

  1. Downloaded Whois utility
  2. Extract the archive into a folder
  3. Then extract the executable file to a directory in your system path

Run WHOIS from a Windows command prompt

Windows Whois is a simple executable so there’s no need to install anything:

  1. Open a Windows command prompt
  2. Type whois -v example.com
  3. Whois will return the output to the terminal

How to use find from the windows command prompt

Because this is a text-based service, there will be something of a “wall of text” output from your whois program, but in that listing, you will see all the same information as you would see from a web-based search: who owns the domain, when it was registered and who with, when it is due for renewal, who the domain is registered to and all sorts of other information about that domain.

To make the Whois output easier to read, redirect its output to a text file that you can then scroll through using a common text editor such as Notepad or Notepad++. Here’s how to write the Whois output to a text file.

From the command prompt, simply type the following (replacing example.com with the domain you’d like to query):

whois -v example.com > example.txt

What does the Whois output mean?

Some of the data included in a Whois query is obvious: The registrant name, address, contact email, phone, and so on. But what about the rest?

  • The Registrar is the company with whom the domain owner registered the domain
  • The Creation Date is when the domain was first registered
  • The Expiration Date is when the domain registration expires
  • The Administrative Contact for the domain is often the website administrator for the domain
  • Name Servers indicate which hosting company hosts the domain name

Why would you need to run Whois?

The first step in registering a new domain name is to determine if the domain you want is available or if someone’s already registered it. If the Whois query doesn’t find the domain name then you can register it right away. If someone already owns the domain, then you’ll either have to choose another domain or contact the owner about purchasing the domain.

You might want to look up when a domain expires, what nameservers are handling the DNS hosting, or you might want to find who the hosting service is so you can lodge a complaint. You may even like a domain name enough to contact the owner about purchasing the domain, though domain owners often charge a premium.

If you change web or email hosting, you will want to query the Whois to find the name servers that will tell you where the domain is hosted.

When you migrate your website and email to a new hosting service, you will need to update the name servers to point at your new hosting service then verify that the name server changes took effect. These are tasks for which you will find the Whois utility an essential part of your toolkit.

How to use find from the windows command prompt

Running Whois in Mac or Linux

Of course, it isn’t just Windows users who would ever run Whois. Windows users just need to add the specific tool to do it; macOS and Linux have a Whois utility built into the system and ready to use. Utilities like Whois are installed by default.

Running Whois on macOS

To run a Whois query on a Mac, just follow these steps:

  1. Open a Terminal window
  2. Type whois example.com at the command prompt
  3. Press Enter

How to use find from the windows command prompt

You should see much the same result as in the Windows example above.

Running Whois on Linux

Running Whois on Linux is almost identical to running it on macOS terminal:

  1. Open a shell to access the command prompt
  2. Type whois example.com
  3. Press Enter

You will also see the same kind of entry as Windows and Mac users.

If the macOS or Linux whois data scrolls by too quickly you can pipe the output to paging utility to scroll through the data at your own pace:

whois example.com | less

If you want to learn more about Whois see How To Tell Who Owns a Domain Using Whois. If you’re a macOS user, you might find, How to flush your DNS cache on macOS useful.

Do you have any special uses for Whois or other DNS utilities such as dig and Nslookup? Please let us know in the comments!

When your computer won’t work properly, you can learn how to repair Windows 10 using command prompt from this article.

By AOMEI / Last Updated April 21, 2021

How do I repair Windows 10 with command prompt?

When there is some problem happens to Windows, you can repair your windows with some basic repair like Windows directory repair, boot directory repair. When the error is too serious, you can run advanced repair like system restore. For Windows 10, you can also use DISM command line utility to repair Windows 10 image. Next, this article will introduce you how to repair Windows 10 using command prompt with five methods.

Method 1. How to repair Windows 10 using SFC?

SFC (System File Checker) is a command-line utility that can scan for corruption in Windows system files and replace any corrupted or missing protected system files with a known good version. When you feel buggy with your computer or notice problems during boot, you can use SFC to diagnose problems and repair it.В

To repair Windows 10 using SFC with detailed steps:

1. Open “Start”, search for the Command Prompt, select it and run as administrator.

2. Then type the command: “sfc /scannow” and press “Enter”.

If SFC is unable to fix the problem, probably the utility cannot get the necessary files from the Windows image, which might have become broken. In this situation, you can use DISM to repair the Windows image.

Method 2. How to repair Windows 10 using DISM?

Windows 10 includes a command-line utility known as DISM (Deployment Image Servicing and Management). DISM command Windows 10 can be used to repair and prepare Windows images, including, Windows Setup, Windows Recovery Environment, and Windows PE. Also, DISM can be used to fix the recovery image within an installation of the operating system.

To repair Windows 10 using DISM commands:

To check whether there is any corruption, Run command line as administrator, then type the following syntaxВ and press “Enter”.

DISM /Online /Cleanup-Image /CheckHealth

To scan the Windows image for any corruption, type below command and hit “Enter”.

DISM /Online /Cleanup-Image /ScanHealth

To fix Windows image, type the following command and hit “Enter”.

DISM /Online /Cleanup-Image /RestoreHealth /Source:repairSource\install.wim

How to use find from the windows command prompt

Method 3. How to reset Windows 10 with command line?

To reset Windows 10 with “Reset this PC”, follow the instructions below:

Type “systemreset -cleanpc” in an elevated command prompt and press “Enter”.В (If your computer cannot boot, you can boot into recovery mode and select “Troubleshoot”, and then choose “Reset this PC”.)

How to use find from the windows command prompt

Method 4. How to run system restore with command prompt?

If the problem is too severe, you can try to restore your Windows 10 to the previous state as long as you have enabled system restore. But, it willВ notВ restoreВ documents, music, emails, or personal files of any kind. If this is what you need, see below.

To run system restore in safe mode, follow the steps below:

1. Start your computer and press “F8” repeatedly until the Windows advanced options menu appears.

2. Click “Safe Mode with command prompt” and press “Enter”. If your computer can boot normally, type “cmd” in the search box and click “Command Prompt” to continue.

3. Sign in using an administrator account if needed. Once the command prompt is showing, enterВ “rstrui.exe” at first in the Command Prompt Window andВ press “Enter” to continue.

How to use find from the windows command prompt

4. This command will bring you to the interface of System Restore. You can either use the recommended restore point or click “Next” to choose an available restore point. Then, follow the instruction to complete system restore.

How to use find from the windows command prompt

Method 5. How to repair Windows 10 with AOMEI.exe?

Besides system restore, you can also repair Windows 10 with AOMEI.exe. AOMEI Backupper is a reliable backup and restore software which is designed for Windows 10/8/7/XP/Visa. You can either backup and restore from graphic users interface or command line. It has some features that Windows built-in tool does not have. For example, you can use AOMEI Backupper to create incremental backup, and you can restore to a dissimilar hardware.

Suppose you have created system image backup with AOMEI Backupper. Before restoring system, you can use a utility named Check Image to check if system image backup is intact and without error.В

Then, use the following steps to restore windows 10 with AOMEI.exe:

1. Navigate to AOMEI Backupper installation directory by typing the following command in command line and press “Enter”. For example: cd C:\Program Files (x86)\AOMEI Backupper.

Note: If you run this command under Windows PE environment, the drive letters might change.

2. Run the following command to start restore: AMBackup /r /t [backup type] /s “[backup location path]” /d [destination location]. For example: To restore the system backup saved in J:\systembackup1 to disk 1. You should type the command: AMBackup /r /t system /s “J:\system backup\systembackup1.adi” /d 1

How to use find from the windows command prompt

Tip: If you need to restore to another computer, AOMEI Backupper “Universal Restore” feature can make this very easy. For example: Run system restore in the image named “systembackup1.adi” to the partition 0 on disk 0 and perform a universal restore. AMBackup /r /t system /s “D:\system backup\systembackup1.adi” /d 0:0 /x

Now you have learned how to repair Windows 10 using command line with five methods. You can choose one based on your preference. It is also suggested to keep backup software AOMEI Backupper installed on your computer to provide continuous protection (try 30-day free trial).В

Also, you can find “Recovery Environment” utility in “Tools” toВ enable the boot option of AOMEI Backupper recovery environment. When system crashes, it enables you to perform backup/restore from boot easily.

If you want to protect unlimited computers within your company, you can pick AOMEI Backupper Technician. В You will be surprised to find that it enables you to copy the installation directory forВ portable version creation. Don’t hesitate to try it out!

Aug 19, 2019
Comment

Windows search can find just about anything on your Windows drive. If you like the feature enough, you can extend the search to other drives on your system. There are other apps/utilities that you can install if you find Windows search isn’t as effective or you can search for files and folders from Command Prompt. Here’s how.

Search for files and folders from Command Prompt

Command Prompt can search a particular drive, or a specific folder for files and folders. By default, assuming you’re running it with ordinary user rights, it opens to your user folder and you may, or may not want to search that particular folder. This is why you need to know how to move Command Prompt to a different location.

If you want to search other non-window drives, you will need to switch to it first with the following command;

Syntax

Example

To move to a different folder, use the command below. The quote marks are only necessary if you have folders that have a space in their names in the path that you’re entering but it’s best to make a habit out of adding them

Syntax

Example

How to use find from the windows command prompt

Search for files by type

The following command allows you to search the current folder for all files of a particular type.

Syntax

Example

How to use find from the windows command prompt

The above command will look for all PNG files in the current directory and its sub-folders. The /s switch tells the command to include sub-folders, and the /b switch displays files without including metadata making the list easy to read.

How to use find from the windows command prompt

Search for files by name

To search for files by name, use the following command;

Syntax

Example

How to use find from the windows command prompt

The above command will look for all files that match the file name you entered regardless of the file type. If you want to narrow the search down by file type, enter the file extension after the period.

Example

Search for folders

To search a folder for sub-folders, use the following command;

Syntax

Example

Remember that the above command will search the folder you enter for sub-directories. If you want to search a different folder, use the cd command to move to where the folder is located and then run the command.

How to use find from the windows command prompt

Search for folder with unknown name

If you’re not sure what the name of a folder is, you can use the following command.

If you want to find specific text in files, in a command line output or elsewhere, you may use the findstr command on Windows to do so.

Findstr is a built-in tool of the Windows operating system that you may run from the command line to find text in files or in command line outputs.

You can use the application to filter command line outputs, search individual files or entire directory structures for files with matching text.

Run findstr /? from the command line to display all parameters and options that “Find String” supports.

Third-party tools like Notepad++, GGRep, or Everything support finding text in files as well.

Using findstr

How to use find from the windows command prompt

You can run findstr from the command line or batch files. Open a new command line prompt by tapping on the Windows-key, typing cmd.exe and selecting the result.

  • /? — display the help text
  • /S — searches the directory and all subdirectories
  • /I — search is not case sensitive
  • /R — use search strings as regular expressions
  • /B — matches patterns at the beginning of lines
  • /P — skip files with non-printable characters
  • /V — print only lines that contain a match
  • /N — print the line number

Here is a list of examples that you may find useful:

  • ipconfig | findstr “192.168” — The command runs ipconfig and returns any result that matches 192.168. Any other result is ignored.
  • netstat | findstr “123.123.123.13” — Runs the netstat command and returns any result that matches the string (in this case the IP address).
  • findstr /c:”windows 10″ windows.txt — Searches the document windows.txt for the string “windows 10”
  • findstr “windows 10” windows txt — Searches for “windows” or “10” in the file.
  • findstr “windows” c:\documents\*.* — Searches any file under c:\documents for the string “windows”.
  • findstr /s /i Windows *.* — Searches every file in the current directory and all subdirectories for the word Windows ignoring letter case.
  • findstr /b /n /r /c:”^ *FOR” *.bas– Returns any line that begins with FOR that are preceded by zero or more spaces. Prints the line number as well.

Findstr is a powerful command that you may use to search for strings in files or to filter command line output. You may use it to scan entire directory structures or drives for files that match the selected string or part of it, and to find specified text in command line outputs quickly.

Advanced options include returning content that is found at the beginning or end of lines, using regular expressions, or using wildcards.

Closing words

Findstr’s main advantage is that it is a built-in tool that you can run on any Windows machine. It is useful to find text in files quickly but works as a tool to filter the output of command line tools as well.

Now you: which program do you use to find text in files?