List folders and subfolders cmd

Asked

Viewed 13,919 times

0

I would like to display the directory name followed by the folders that are inside it in the order.

I tested the remote:

dir /s /b /o:g /ad

And the output was generated like this:

C:\Users\JG\Pictures\Animes
C:\Users\JG\Pictures\Series
C:\Users\JG\Pictures\Nova pasta
C:\Users\JG\Pictures\Series\Teen Wolf

But I wish it was generated like this:

C:\Users\JG\Pictures\Animes
C:\Users\JG\Pictures\Series
C:\Users\JG\Pictures\Series\Teen Wolf
C:\Users\JG\Pictures\Nova pasta

Does anyone know any command or attribute that does this?

  • The Tree command meets?

  • With the Tree command I get an output like this? Why do I need to record this output in a file and then play in Excel.

  • You can do Tree > example.txt

  • 1

    It worked with Tree, but I couldn’t get a nice way out. txt gets a few more characters... But that’s something. Thanks!

3 answers

2

You can try the command without the colon (":"), see:

dir /s /b /OG /AD

2

Updated - when using Sort set as desired :

dir /a:d /s /b | sort
  • I tried to sort by name ("o:n"), but it also didn’t work. The output was the same. T T

  • Yaaaaaaay ~ It worked!!!! Wow!!! Thank you very much, Claudio w^

  • Hello @Miuinwonderland, a tip. When you have an answer that satisfies your question select it as the best answer in the green mark.

0

Would that be commando that you seek to generate the listing with full path sorted by name?

ordenar por nome adicione: /on (dir /s /b /o:g /ad /on)

for /f "tokens=*delims= " %i in ('dir /s /b /o:g /ad /on')do @echo/%~fi

In the command line:

dir /s /b /o:g /ad /on
rem :: num looping for :: 
for /f "tokens=*delims= " %i in ('dir /s /b /o:g /ad /on')do @echo/"%~fi

In the bat file:

@echo off & dir /s /b /o:g /ad /on
rem :: num looping for :: 
@echo off & for /f "tokens=*delims= " %%i in ('dir /s /b /o:g /ad /on')do echo/%%~fi

inserir a descrição da imagem aqui

Browser other questions tagged

You are not signed in. Login or sign up in order to post.