This page on Command Line Syntax says I can use something like *.txt to search for a file.

For example, folder Z contains a.txt, b.txt, c.doc, etc.

Now, after I've changed the working directory to Z, what follows next?

It seems that I can't type that straightaway, as this will give me the following:

'*.txt' is not recognized as an internal or external command, operable program or batch file.

How do I go about doing it?

  • Please specify an operating system/shell. And even then the question is not really about programming. – Yuval F Oct 18 '09 at 11:52
  • 2
    What does "sth" mean? Please use English, where possible. – S.Lott Oct 18 '09 at 11:56
  • sth means "something" – Shadi Almosri Oct 18 '09 at 12:09
  • 4
    We guessed as much, but guessing what questions mean shouldn't really be necessary. – pavium Oct 18 '09 at 13:11

Well the wildcard isn't the command :). The command to list the directory contents in the windows console is dir. So you'd have:

dir *.txt
  • ls if you are on *nix paltform – Amarghosh Oct 18 '09 at 11:54

The link is explaining that 7-zip does not use DOS style wildcards. For example on a DOS or Windows command shell:

dir *.txt

will list all files ending in txt, and:

dir *.*

will list all files in the folder. On a UNIX/LINUX shell, the equivalent commands are:

ls *.txt


ls *

DOS/Windows files have a 3 character extension, and the . (dot) is used to separate the name from the extension. On Linux and UNIX, there is no extension, but it is common practice to include a . (dot) in the filename followed by one or more characters. On a UNIX system, saying:

ls *.*

will only list files which have a . (dot) in the name.

7Zip uses the Linux/UNIX style of wildcard.

  • Windows files aren't required to have an extension at all - it's just cmd.exe that handles wildcards such as *.* specially. But the filesystem, and almost all applications, have no limits on what the file name can be. (The filesystem itself even accepts | < > ? *, like ext3 does.) – user1686 Oct 18 '09 at 12:22
  • dir is available on unix too. – Lee B Oct 18 '09 at 13:11
  • 1
    @grawity, this is almost the opposite of how I understood Windows to work. I've always had the impression that in Windows the type of file is embodied in the extension, and changing it causes dire warnings. Does this mean Windows is becoming more Unix-like? – pavium Oct 18 '09 at 13:19
  • Just for the record... The file extension in Windows is a hint as to the file's type, and the registry has default mappings on what to do if you double-click a file, much the same as a .sh in Linux. (Also, the three-character convention is not a rule, and nowadays is often ignored.) Example: try renaming an .html or .xml (or a formatted doc saved as .rtf) file manually to .txt, then double-clicking (or Enter) to open it. Notepad will happily pop up. Doing that with .doc or .exe file will try to show the binary data as text in Notepad, which looks mangled. – Jon Coombs May 7 '15 at 23:30
  • note that dir *.txt doesn't list all files ending in txt but all files with an extension that begins with "txt" because 8.3 file names are also matched – phuclv Jun 17 '19 at 16:40

This will find all files with a txt extension (in the current folder):

dir *.txt

This will find all files with a txt extension including sub-directories (so you could run this command from a parent folder):

dir /s *.txt


If you are in Powershell there ls is an alias of Get-Childitem, so the unix syntax can be directly used.

ls *.txt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy