2012-05-09 14 views
19

Ho bisogno di elencare i nomi dei file e memorizzarli come file di testo!Come elencare i file usando i comandi dos?

Quello che ho fatto è, ho usato i seguenti comandi DOS

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

Quello che fa è che, memorizza i nomi dei file presenti nella directory xyz nonché le dimensioni, ora e data dei file !

Come ottenere solo i nomi dei file?

risposta

37

Provare dir /b, per formato nudo.

dir /? vi mostrerà la documentazione di cosa è possibile fare con il comando dir. Ecco l'uscita dalla mia macchina Windows 7:

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

Purtroppo il comando nuda/B e/Le opzioni W e/D nuda ordinate per colonna non funzionano insieme. Non conosco il modo per sopprimere il riepilogo e tuttavia ottenere facilmente i dati in ordine di colonna in DOS. – ggb667

22

Se si desidera solo per ottenere i nomi di file e non i nomi delle directory poi utilizzano:

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

Se si desidera filtrare per un tipo specifico ad esempio xml: dir * .xml/b/a-d/s | ordina> files1.txt –

Problemi correlati