Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Quick DOS Question

  • 28-02-2007 02:12PM
    #1
    Registered Users, Registered Users 2 Posts: 7,754 ✭✭✭


    I'm trying to print a list of folders and subfolders from one of my drives into a textfile.

    At the moment I'm using:

    dir /s /on *.* > Tree.txt

    The one problem with this is it's also printing the files contained in each directory. Is there any way to print the folder names only?

    Thanks.


Comments

  • Closed Accounts Posts: 1,974 ✭✭✭mick.fr


    dir /s /ad


  • Registered Users, Registered Users 2 Posts: 1,399 ✭✭✭WetDaddy


    Man, it's been a while since I worked with DOS, but you could try removing the second asterisk in your 'file' listing parameter. So, something like this:

    dir /s /on *. > Tree.txt


    That has the potential to also give you files without extensions, mind you. But these aren't too common on Windows / DOS systems, with the exception of things like the hosts file.

    If you're happy enough manually removing a few, go with that. Otherwise, if you want a GUARANTEED directory-only listing, there's probably a switch with dir you can use. Either that, or maybe specifiy a filesize of 0 or something?


  • Registered Users, Registered Users 2 Posts: 1,399 ✭✭✭WetDaddy


    mick.fr wrote:
    dir /s /ad

    Yep, that'll do it better than my way ;) That'll teach me to try and be the first to answer a techy post!

    But hey, maybe you learned something from me. Like to call them directories, and not folders, and to keep doing it as get older and appear wizened & cantankerous.

    Oh, by the way, you might want to put in: /adh (notice the extra 'h') to show you any hidden directories too, if desired.


  • Registered Users, Registered Users 2, Paid Member Posts: 21,534 ✭✭✭✭Alun


    deathfunk wrote:
    Oh, by the way, you might want to put in: /adh (notice the extra 'h') to show you any hidden directories too, if desired.
    Actually dir /adh will show you only the hidden directories, dir /ad will show all of them (including the hidden ones). All it's doing is showing those directory entries that match all of the given attributes on the /a switch.


  • Registered Users, Registered Users 2 Posts: 7,754 ✭✭✭ianmc38


    Thanks for the info. Micks suggestion worked perfectly for me!


  • Advertisement
Advertisement