How does the Win10 system quickly find files through a command prompt?

  

Many users know that in the Win10 system, you can use the search function in this computer to search for the required files, and you can let Xiaona help you search, but the search is quite long compared to using CMD search. You can use the CMD lookup method to speed up the search.

for /r Usage:

Using the find command under Linux, it is convenient to find files, then there is no similar command in Win10 to traverse the directory and find the file by file name What? The answer is:

The for /r command under Win10 has similar functionality to the find command under Linux, using a syntax similar:

find /r directory name % variable name in (match mode 1, matching mode 2) do command

matching mode can be wild like:

*.jpg: all files with .jpg suffix.

*test*: All files containing test in their name.

Note:

1. Match at least one * in the matching mode.

2. The matching content is limited to the file name and will not match the directory name.

If only the file name is found and output, the command following the do can use the @echo% variable name, ie:

for /r directory name %i in (match mode 1, match mode 2) do @echo %i

Common examples:
# List all files in the TestDir directory and all subdirectories C:\\Users\\cashey\\Desktop>for /r TestDir %i in (*) do @echo %i C:\\Users\\cashey\\Desktop\\TestDir\\b.jpg C:\\Users\\cashey\\Desktop\\TestDir\\c.png C:\\Users\\cashey\\Desktop\\TestDir\\doc\\1 .txt C:\\Users\\cashey\\Desktop\\TestDir\\doc\\2.txt C:\\Users\\cashey\\Desktop\\TestDir\\src\\test.py # Find all txt files in the TestDir directory and all subdirectories C :\\Users\\cashey\\Desktop>for /r TestDir %i in (*.txt) do @echo %i C:\\Users\\cashey\\Desktop\\TestDir\\doc\\1.txt C:\\Users\\cashey\\Desktop\\ TestDir\\doc\\2.txt # Find all txt and jpg files in the TestDir directory and all subdirectories C:\\Users\\cashey\\Desktop>for /r TestDir %i in (*.txt,*.jpg) do @echo %i C:\\Users\\cashey\\D Esktop\\TestDir\\b.jpg C:\\Users\\cashey\\Desktop\\TestDir\\doc\\1.txt C:\\Users\\cashey\\Desktop\\TestDir\\doc\\2.txt # Find out in the TestDir directory and all subdirectories All files containing test files C:\\Users\\cashey\\Desktop>for /r TestDir %i in (*test*) do @echo %i C:\\Users\\cashey\\Desktop\\TestDir\\src\\test.py

Points to note:

If there is no * in the matching mode, it will not exactly match the file name, but will output the result of the matching mode in all subdirectories, like this: Br> # The directory does not actually contain any files named abc C:\\Users\\cashey\\Desktop>for /r TestDir %i in (abc) do @echo %i C:\\Users\\cashey\\Desktop\\TestDir\\ Abc C:\\Users\\cashey\\Desktop\\TestDir\\doc\\abc C:\\Users\\cashey\\Desktop\\TestDir\\src\\abc

The above output is generally not what you expected, at least 1 in the pattern. *#

If you are used to this type of search, you will feel that this is faster than expected and can speed up your work. Work more efficiently and save more time.

Copyright © Windows knowledge All Rights Reserved