ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Powershell Directory Tree

    Scheduled Pinned Locked Moved IT Discussion
    powershellfolder treedirectory tree
    8 Posts 2 Posters 6.6k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • DustinB3403D
      DustinB3403
      last edited by

      Hey All,

      Looking for a decent way to scan for and create a directory tree 3 levels deep, and not list any files within the tree it's self.

      I have this Get-ChildItem -Path Q:\ -Recurse | Export-Csv C:\File-Tree.cs which works mostly, but is adding all of the files and every sub folder.

      Any input to help simplify this?

      dafyreD 1 Reply Last reply Reply Quote 1
      • DustinB3403D
        DustinB3403
        last edited by

        I ideally would like something along these lines.

        Q:\
        - - - Q:\Folder 1
        - - - - Q:\Folder 1\Sub 1
        - - - - - Q:\Folder 1\Sub 1\ 
        
        Q:\
        - - - Q:\Folder 2
        - - - - Q:\Folder 2\Sub 1
        - - - - - Q:\Folder 2\Sub 1\ 
        

        So on and so forth.

        1 Reply Last reply Reply Quote 0
        • dafyreD
          dafyre @DustinB3403
          last edited by dafyre

          @dustinb3403

          get-childitem -Path Q:\ -Recurse -Directory -Depth 3|export-csv C:\file-tree.csv

          Just missing -directory and -Depth options.

          Edit: You added additional requirements after I posted that, lol.

          DustinB3403D 1 Reply Last reply Reply Quote 2
          • DustinB3403D
            DustinB3403 @dafyre
            last edited by

            @dafyre said in Powershell Directory Tree:

            @dustinb3403

            get-childitem -Path Q:\ -Recurse -Directory -Depth 3|export-csv C:\file-tree.csv

            Just missing -directory and -Depth options.

            Testing now.

            dafyreD 1 Reply Last reply Reply Quote 0
            • dafyreD
              dafyre @DustinB3403
              last edited by

              @dustinb3403 said in Powershell Directory Tree:

              @dafyre said in Powershell Directory Tree:

              @dustinb3403

              get-childitem -Path Q:\ -Recurse -Directory -Depth 3|export-csv C:\file-tree.csv

              Just missing -directory and -Depth options.

              Testing now.

              Slight modification:

              get-childitem -Path Q:\ -Recurse -Directory -Depth 3|select FullName|export-csv C:\file-tree.csv

              Will get you just the folder list.

              1 Reply Last reply Reply Quote 0
              • DustinB3403D
                DustinB3403
                last edited by

                It went more than the 3 directories though.

                It's much cleaner though.

                1 Reply Last reply Reply Quote 1
                • DustinB3403D
                  DustinB3403
                  last edited by

                  I got it sorted, computer math 😛

                  2 means 2 from the directory its starting from (aka) 1 deeper than what I was thinking.

                  Set it to 1 deep and I get two folders.

                  Thanks!

                  dafyreD 1 Reply Last reply Reply Quote 3
                  • dafyreD
                    dafyre @DustinB3403
                    last edited by

                    @dustinb3403 You're welcome ! Glad you got it sorted.

                    1 Reply Last reply Reply Quote 1
                    • 1 / 1
                    • First post
                      Last post