Windows find all files command line

поиск find

Выполняет поиск строки текста в файле или файлах и отображает строки текста, содержащие указанную строку. 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 /v Отображает все строки, не содержащие указанный объект . Displays all lines that don’t contain the specified .
/C /c Подсчитывает количество строк, содержащих указанный объект , и отображает итоговое значение. Counts the lines that contain the specified and displays the total.
/n /n Предшествует каждой строке с номером строки файла. Precedes each line with the file’s line number.
/i /i Указывает, что при поиске регистр не учитывается. Specifies that the search is not case-sensitive.
[«/OFF» [строка]] [/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.
[ :][

] Указывает расположение и имя файла, в котором выполняется поиск указанной строки. Specifies the location and name of the file in which to search for the specified string. /? /? Отображение справки в командной строке. Displays help at the command prompt.

Комментарии Remarks

Если вы не используете /i, эта команда ищет именно то, что указано для String. If you don’t use /i, this command searches for exactly what you specify for string. Например, эта команда обрабатывает символы и по a — A разному. For example, this command treats the characters a and A differently. Однако при использовании параметра /i Поиск выполняется без учета регистра, а в a A качестве того же символа обрабатывается и. If you use /i, however, the search becomes non-case-sensitive, 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.

Параметры и параметры командной строки для команды Find можно вводить в любом порядке. You can type parameters and command-line options for the find command in any order.

Нельзя использовать подстановочные знаки (* и ?) в именах файлов или расширениях, указанных при использовании этой команды. You can’t use wildcards (* and ?) in file names or extensions that you specify while using this command. Для поиска строки в наборе файлов, указанных с помощью подстановочных знаков, эту команду можно использовать в команде for . To search for a string in a set of files that you specify with wildcards, you can use this command within a for command.

При использовании /c и /v в одной командной строке эта команда отображает количество строк, которые не содержат указанную строку. 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. При указании параметра /c и /n в той же командной строке команда Find игнорирует параметр /n. 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.

Примеры Examples

Чтобы отобразить все строки из Pencil.AD , которые содержат строку резкость карандаша, введите: To display all lines from pencil.ad 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.» в файле report.doc введите: in the report.doc file, type:

Для поиска набора файлов можно использовать команду Find в команде for . To search for a set of files, you can use the find command within the for command. Чтобы найти в текущем каталоге файлы с расширением bat, которые содержат строку строки, введите следующую команду: To search the current directory for files that have the extension .bat and that contain the string PROMPT, type:

Чтобы найти и отобразить имена файлов на диске C, которые содержат строковый ЦП, выполните поиск на жестком диске с помощью вертикальной черты (|), чтобы направить выходные данные команды dir в команду Find следующим образом: To search your hard disk to find and display the file names on drive C that contain the string CPU, use the pipe (|) to direct the output of the dir command to the find command as follows:

Так как поиск при поиске выполняется с учетом регистра, а dir создает прописные буквы, необходимо либо ввести строковый процессор в верхнем регистре, либо использовать параметр командной строки /i с командой Find. Because find searches are case-sensitive and dir produces uppercase output, you must either type the string CPU in uppercase letters or use the /i command-line option with find.

How to do a simple file search in cmd

I want to quickly search for a file given its name or part of its name, from the windows command line (not power shell). This is similar to opening explorer and using the search box at the top.

Note: dir can search based on a string template but it will not search in the subdirectories.

Note2: findstr can be used to search for a token inside files and has a recursivity flag; it’s funny that a more complex find can be easily discovered .

5 Answers 5

dir /s *foo* searches in current folder and sub folders.

It finds directories as well as files.

/s Lists every occurrence of the specified file name within the specified directory and all subdirectories.

searches for all txt file in the directory tree. Before using it just change the directory to root using

you can also export the list to a text file using

and search within using

EDIT 1: Although this dir command works since the old dos days but Win7 added something new called Where

will search for exe & dll in the drive c:\Windows as suggested by @SPottuit you can also copy the output to the clipboard with

just wait for the prompt to return and don’t copy anything until then.

EDIT 2: If you are searching recursively and the output is big you can always use more to enable paging, it will show — More — at the bottom and will scroll to the next page once you press SPACE or moves line by line on pressing ENTER

how do I find all exe files using command line for windows?

I’m a newbie. I am trying to figure out how to use the command line. Please could you tell me what command I should enter so that I can get a list of all the exe files on my computer. thanks.

4 Answers 4

You can use the dir functionality to search the directory and all of its children directories while filtering on a particular file type.

If you want to find all the executable files that are on the path and/or in the current directory, i.e., all the files you can run from the command line without specifying a path, this should work:

To get names of all .exe files , that are currently running then type tasklist in cmd.

Here’s another method I use a lot for tasks like this.

Open powershell and navigate to your root directory by entering the command

cd stands for change directory, and is an alias for the command «Set-Location». We are setting the location to C:/

Next run the following command:

Get-ChildItem is a function that gets the files and folders in a file system drive, and runs on whatever directory you’re current at by default.

-Filter «*.exe» is an argument that specifies to only find filenames which end in «.exe». (The * is a type of regular expression notation).

-Recurse is an argument that specifies to search all child directories. This will make your function run on «C:/», but also all child directories of C:/, and all child directories of those directories and so on. This will allow you to search the entire drive.

Command to list all files in a folder as well as sub-folders in windows

I tried searching for a command that could list all the file in a directory as well as subfolders using a command prompt command. I have read the help for «dir» command but coudn’t find what I was looking for. Please help me what command could get this.

6 Answers 6

The below post gives the solution for your scenario.

/S Displays files in specified directory and all subdirectories.

/B Uses bare format (no heading information or summary).

/O List by files in sorted order.

If you want to list folders and files like graphical directory tree, you should use tree command.

There are various options for display format or ordering.

Check example output.

Answering late. Hope it help someone.

An addition to the answer: when you do not want to list the folders, only the files in the subfolders, use /A-D switch like this:

An alternative to the above commands that is a little more bulletproof.

It can list all files irrespective of permissions or path length.

I have a slight issue with the use of C:\NULL which I have written about in my blog

But nevertheless it’s the most robust command I know.

If you simply need to get the basic snapshot of the files + folders. Follow these baby steps:

  • Press Windows + R
  • Press Enter
  • Type cmd
  • Press Enter
  • Type dir -s
  • Press Enter

Following commands we can use for Linux or Mac. For Windows we can use below on git bash.

List all files, first level folders, and their contents

List all first-level subdirectories and files

How to find a file or folder in MS-DOS or Windows command line

You can find any file on your computer using MS-DOS providing you know the name of the file or the program that created the file.

If you are unsure where the file may be on the computer, you must be at the root directory of the computer. Meaning, you must be at C:\> to get to this prompt, type the following command.

Once at the root directory or the directory you believe the file to be in, type any of the following commands.

If, for example, you knew that the file had bob somewhere in the file, you would type:

The above example uses wildcards (the asterisks). Also, it uses the /s command switch to tell the dir command to search the current directory, and all its subdirectories.

If you cannot recall any of the names of the files but recall that they were created in Microsoft Excel you could, for example, type:

In the above example, knowing Excel files often end with the .xls file extension, we use the wild character, telling the computer to search for any file ending with the .xls extension. If you don’t know extension of your file, you can find a listing of the majority of extensions and the associated program on our MS-DOS extensions page.

Finally, once you have found the file, you must interpret the output of your search and be able to change directories to get to that file.

Below is an example of the results found when typing dir *bob*.* /s as mentioned in an earlier example.

Читайте также:  Windows 10 home отключить проверку цифровой подписи драйверов
Оцените статью