2012-05-09 10 views
19

ファイルの名前をリストし、テキストファイルとして保存する必要があります。dosコマンドを使ってファイルをリストする方法は?

は私がやった、私は次のDOSは、これが何をするか

x:\xyz> dir *.* > files.txt 

が、それはファイルのサイズ、日付と時刻だけでなく、ディレクトリXYZに存在するファイルの名前を格納し、ということであるコマンドを使用しました!

ファイル名の取得方法は?

答えて

37

dir /bのベアフォーマットについて試してください。

dir /?は、dirコマンドでできることのドキュメントを表示します。あなただけファイル名ではなくが、その後使用したディレクトリ名を取得したい場合は

C:\>dir /? 
Displays a list of files and subdirectories in a directory. 

DIR [drive:][path][filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L] [/N] 
    [/O[[:]sortorder]] [/P] [/Q] [/R] [/S] [/T[[:]timefield]] [/W] [/X] [/4] 

    [drive:][path][filename] 
       Specifies drive, directory, and/or files to list. 

    /A   Displays files with specified attributes. 
    attributes D Directories    R Read-only files 
       H Hidden files    A Files ready for archiving 
       S System files    I Not content indexed files 
       L Reparse Points    - Prefix meaning not 
    /B   Uses bare format (no heading information or summary). 
    /C   Display the thousand separator in file sizes. This is the 
       default. Use /-C to disable display of separator. 
    /D   Same as wide but files are list sorted by column. 
    /L   Uses lowercase. 
    /N   New long list format where filenames are on the far right. 
    /O   List by files in sorted order. 
    sortorder N By name (alphabetic)  S By size (smallest first) 
       E By extension (alphabetic) D By date/time (oldest first) 
       G Group directories first - Prefix to reverse order 
    /P   Pauses after each screenful of information. 
    /Q   Display the owner of the file. 
    /R   Display alternate data streams of the file. 
    /S   Displays files in specified directory and all subdirectories. 
    /T   Controls which time field displayed or used for sorting 
    timefield C Creation 
       A Last Access 
       W Last Written 
    /W   Uses wide list format. 
    /X   This displays the short names generated for non-8dot3 file 
       names. The format is that of /N with the short name inserted 
       before the long name. If no short name is present, blanks are 
       displayed in its place. 
    /4   Displays four-digit years 

Switches may be preset in the DIRCMD environment variable. Override 
preset switches by prefixing any switch with - (hyphen)--for example, /-W. 
+0

および/ここに私のWindows 7マシンから出力され列スイッチで並べ替えたWと/ Dは、一緒に動作しません。私は要約を抑止し、DOSで簡単に列順にデータを取得する方法は知られていません。 – ggb667

22

:残念ながら/ B裸コマンド

dir /b /a-d > file.txt 
+0

xml:dir * .xml/b/a-d/sのような特定のタイプをフィルタリングする場合は、ソート>ファイル1。 –

関連する問題