次の方法で共有


dir

ディレクトリのファイルとサブディレクトリの一覧を表示します。 パラメーターを指定せずに使用した場合、このコマンドはディスクのボリューム ラベルとシリアル番号を表示し、その後にディスク上のディレクトリとファイルの一覧を表示します (名前と各ファイルが最後に変更された日時を含む)。 ファイルの場合、このコマンドは名前拡張子とサイズをバイト単位で表示します。 また、このコマンドは、一覧表示されているファイルとディレクトリの合計数、その累積サイズ、およびディスクに残っている空き領域 (バイト単位) も表示します。

The dir command can also run from the Windows Recovery Console, using different parameters. 詳細については、「Windows Recovery Environment (WinRE)」を参照してください。

Syntax

dir [<drive>:][<path>][<filename>] [...] [/p] [/q] [/w] [/d] [/a[[:]<attributes>]][/o[[:]<sortorder>]] [/t[[:]<timefield>]] [/s] [/b] [/l] [/n] [/x] [/c] [/4] [/r]

Parameters

Parameter Description
[<drive>:][<path>] 一覧を表示するドライブとディレクトリを指定します。
[<filename>] 一覧を表示する特定のファイルまたはファイルのグループを指定します。
/p 一度に 1 つの一覧の画面を表示します。 次の画面を表示するには、任意のキーを押します。
/q ファイルの所有権情報を表示します。
/w 各行に最大 5 つのファイル名またはディレクトリ名を含むワイド形式で一覧を表示します。
/d Displays the listing in the same format as /w, but the files are sorted by column.
/a[[:]<attributes>] 指定した属性を持つディレクトリとファイルの名前のみを表示します。 このパラメーターを使用しない場合、このコマンドは、非表示ファイルとシステム ファイルを除くすべてのファイルの名前を表示します。 If you use this parameter without specifying any attributes, the command displays the names of all files, including hidden and system files. The list of possible attributes values are:
  • d - Directories
  • h - Hidden files
  • s - System files
  • l - Reparse points
  • r - Read-only files
  • a - Files ready for archiving
  • i - Not content indexed files
これらの値の任意の組み合わせを使用できますが、スペースを使用して値を区切らないでください。 必要に応じて、コロン (:)区切り記号) を使用することも、"not" を意味するプレフィックスとしてハイフン (-) を使用することもできます。 For example, using the -s attribute won't show the system files.
/o[[:]<sortorder>] Sorts the output according to sortorder, which can be any combination of the following values:
  • n - Alphabetically by name
  • e - Alphabetically by extension
  • g - Group directories first
  • s - By size, smallest first
  • d - By date/time, oldest first
  • - プレフィックスを使用して並べ替え順序を逆にする
複数の値は、リストする順序で処理されます。 複数の値をスペースで区切らないでくださいが、必要に応じてコロン (:)を使用できます。

If sortorder isn't specified, dir /o lists the directories alphabetically, followed by the files, which are also sorted alphabetically.

/t[[:]<timefield>] 表示または並べ替えに使用する時刻フィールドを指定します。 The available timefield values are:
  • c - Creation
  • a - Last accessed
  • w - Last written
/s 指定したディレクトリおよびすべてのサブディレクトリ内で、指定したファイル名が出現するたびに一覧表示されます。
/b ディレクトリとファイルのベア リストを、追加情報なしで表示します。 The /b parameter overrides /w.
/l 小文字を使用して、並べ替えられていないディレクトリ名とファイル名を表示します。
/n 画面の右端にファイル名を含む長いリスト形式が表示されます。
/x 8dot3 以外のファイル名に対して生成された短い名前を表示します。 The display is the same as the display for /n, but the short name is inserted before the long name.
/c 桁区切り記号をファイル サイズで表示します。 これが既定の動作です。 Use /-c to hide separators.
/4 年を 4 桁の形式で表示します。
/r ファイルの代替データ ストリームを表示します。
/? コマンド プロンプトにヘルプを表示します。

Remarks

  • To use multiple filename parameters, separate each file name with a space, comma, or semicolon.

  • You can use wildcard characters (* or ?), to represent one or more characters of a file name and to display a subset of files or subdirectories.

  • ワイルドカード文字 ( *) を使用して、次に例を示す任意の文字列の代わりに使用できます。

    • dir *.txt .txt、.txt1、.txt_old など、.txtで始まる拡張子を持つ現在のディレクトリ内のすべてのファイルが一覧表示されます。

    • dir read *.txt には、.txt、.txt1、.txt_old など、.txtで始まる、読み取りで始まる現在のディレクトリ内のすべてのファイルが一覧表示されます。

    • dir read *.* には、現在のディレクトリ内の任意の拡張子で読み取りで始まるすべてのファイルが一覧表示されます。

    アスタリスクワイルドカードは常に短いファイル名マッピングを使用するため、予期しない結果が得られる可能性があります。 たとえば、次のディレクトリには 2 つのファイル (t.txt2 と t97.txt) が含まれています。

    C:\test>dir /x
    Volume in drive C has no label.
    Volume Serial Number is B86A-EF32
    
    Directory of C:\test
    
    11/30/2004  01:40 PM <DIR>  .
    11/30/2004  01:40 PM <DIR> ..
    11/30/2004  11:05 AM 0 T97B4~1.TXT t.txt2
    11/30/2004  01:16 PM 0 t97.txt
    

    dir t97\*を入力すると、ファイル t97.txtが返される可能性があります。 However, typing dir t97\* returns both files, because the asterisk wildcard matches the file t.txt2 to t97.txt by using its short name map T97B4~1.TXT. 同様に、「 del t97\* 」と入力すると、両方のファイルが削除されます。

  • 疑問符 (?) は、名前の 1 文字の代わりに使用できます。 たとえば、「 dir read???.txt 」と入力すると、現在のディレクトリ内のファイルのうち、読み取りで始まり、その後に最大 3 文字の .txt 拡張子が付いたファイルが一覧表示されます。 これには、Read.txt、Read1.txt、Read12.txt、Read123.txt、および Readme1.txtが含まれますが、Readme12.txtは含まれません。

  • If you use /a with more than one value in attributes, this command displays the names of only those files with all the specified attributes. For example, if you use /a with r and -h as attributes (by using either /a:r-h or /ar-h), this command will only display the names of the read-only files that aren't hidden.

  • If you specify more than one sortorder value, this command sorts the file names by the first criterion, then by the second criterion, and so on. For example, if you use /o with the e and -s parameters for sortorder (by using either /o:e-s or /oe-s), this command sorts the names of directories and files by extension, with the largest first, and then displays the final result. 拡張子によるアルファベット順の並べ替えでは、拡張子のないファイル名が最初に表示され、次にディレクトリ名が表示され、次に拡張子が付いたファイル名が表示されます。

  • If you use the redirection symbol (>) to send this command's output to a file, or if you use a pipe (|) to send this command's output to another command, you must use /a:-d and /b to only list the file names. You can use filename with /b and /s to specify that this command is to search the current directory and its subdirectories for all file names that match filename. このコマンドは、検索するファイル名ごとに、ドライブ文字、ディレクトリ名、ファイル名、およびファイル名拡張子 (1 行に 1 つのパス) のみを一覧表示します。 Before you use a pipe to send this command's output to another command, you should set the TEMP environment variable in your Autoexec.nt file.

Examples

すべてのディレクトリをアルファベット順、ワイド形式で 1 つずつ表示し、各画面の後に一時停止するには、ルート ディレクトリが現在のディレクトリであることを確認し、次のように入力します。

dir /s/w/o/p

出力には、ルート ディレクトリ、サブディレクトリ、ルート ディレクトリ内のファイル (拡張機能を含む) が一覧表示されます。 このコマンドでは、ツリー内の各サブディレクトリのサブディレクトリ名とファイル名も一覧表示されます。

To alter the preceding example so that dir displays the file names and extensions, but omits the directory names, type:

dir /s/w/o/p/a:-d

ディレクトリの一覧を印刷するには、次のように入力します。

dir > prn

When you specify prn, the directory list is sent to the printer that is attached to the LPT1 port. If your printer is attached to a different port, you must replace prn with the name of the correct port.

You can also redirect output of the dir command to a file by replacing prn with a file name. パスを入力することもできます。 For example, to direct dir output to the file dir.doc in the Records directory, type:

dir > \records\dir.doc

If dir.doc does not exist, dir creates it, unless the Records directory does not exist. その場合、次のメッセージが表示されます。

File creation error

ドライブ C のすべてのディレクトリに .txt 拡張子を持つすべてのファイル名の一覧を表示するには、次のように入力します。

dir c:\*.txt /w/o/s/p

The dir command displays, in wide format, an alphabetized list of the matching file names in each directory, and it pauses each time the screen fills until you press any key to continue.