Windows find all files with name

Windows find all files with name

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.
[ :][

] Specifies the location and name of the file in which to search for the specified string. /? Displays help at the command prompt.

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 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.

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. To search for a string in a set of files that you specify with wildcards, you can use this command within a for 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.

Examples

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.» in the report.doc file, type:

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

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:

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.

поиск 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.

Find all files in a folder

I am looking to create a program that finds all files of a certain type on my desktop and places them into specific folders, for example, I would have all files with .txt into the Text folder.

Any ideas what the best way would be to accomplish this? Thanks.

I have tried this:

It was not successful in finding all of the files.

3 Answers 3

A lot of these answers won’t actually work, having tried them myself. Give this a go:

It will move all .txt files on the desktop to the folder TextFiles .

First off; best practice would be to get the users Desktop folder with

Then you can find all the files with something like

Note that with the above line you will find all files with a .txt extension in the Desktop folder of the logged in user AND all subfolders.

Then you could copy or move the files by enumerating the above collection like

Please note that you will have to include the filename in your Copy() (or Move() ) operation. So you would have to find a way to determine the filename of at least the extension you are dealing with and not name all the files the same like what would happen in the above example.

With that in mind you could also check out the DirectoryInfo and FileInfo classes. These work in similair ways, but you can get information about your path-/filenames, extensions, etc. more easily

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

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

Читайте также:  Linux список команд для работы
Оцените статью