List Directory and Files .bat

3

Hi, I'm trying to list a directory with its contents in batch code and save it in a txt with the name of the date.txt, what I need is something like a gene tree I've tried with:

dir /s /b > Listar.txt dir /s > Listar.txt

and it's not what I need, I leave a picture so you can see how I would need to stay, I hope you can help me

    
asked by Tony 31.07.2018 в 16:11
source

2 answers

1

What you want can be achieved with the tree command .

  

tree : Allows the user to view a list of files and folders   in an easy to read list.

using the following options:

  

/ f : Display the file names in each directory

     

/ a : extension characters used to link lines, instead of graphic characters. / a is used with code pages that do not support graphic characters and to send results to printers that do not interpret graphic characters correctly.

This would be the call:

tree <Directorio> /f /a > Listar.txt 

More information: tree command (English)

This is an example of how it would be saved in your file:

Volume serial number is 1A4C-12AB
C:\myData\
|   art_dum.png
|   cockpit.png
|         
|   \---particles
|       |   default.html
|       |   
|       +---css
|       |       doc.txt
|       |       site.min.css
|       |       
|       +---fonts
|       |   +---Material
|       |   |       MaterialIcons-Regular.eot
|       |   |       MaterialIcons-Regular.ttf
|       |   |       MaterialIcons-Regular.woff
|       |   |       MaterialIcons-Regular.woff2
|       |   |       
|       |   +---NimbusMono
|       |   |       nimbusmono-regular-webfont.ttf
|       |   |       nimbusmono-regular-webfont.woff
|       |   |       nimbusmono-regular-webfont.woff2
|       |   |       
|       |   \---roboto
|       |           Roboto-Bold.woff
|       |           Roboto-Bold.woff2
|       |           Roboto-Light.woff
|       |           Roboto-Light.woff2
|       |           Roboto-Medium.woff
|       |           Roboto-Medium.woff2
|       |           Roboto-Regular.woff
|       |           Roboto-Regular.woff2
|       |           
|       \---js
|               site.min.js
|               |                           
\---tototita
        archivo.bat
    
answered by 31.07.2018 / 16:15
source
0

Try with

set MIFECHA=%DATE:/=-%
set MI_DIRECTORIO_BASE=D:\TEMP
tree %MI_DIRECTORIO_BASE% /F /A >%MIFECHA%.txt
    
answered by 31.07.2018 в 16:50