• Copying Folder Names Into Excel

    Author
    Topic
    #2334767

    Is there a way to copy Folder names (not file names) into Excel 365 without using macros? I am running Windows 10 and Office 365. I could use a 3rd party software if it was free. Thanks for any help you might offer.

    Viewing 2 reply threads
    Author
    Replies
    • #2335084

      You can use Total Commander https://www.ghisler.com/, which is shareware that you can try with no limitations. In Total Commander, highlight the folders whose names you want to copy. Then click MARK and then COPY SELECTED NAMES TO CLIPBOARD. Another option is COPY NAMES WITH PATH. Once in Clipboard, paste into Excel spreadsheet.

      Dell XPS17, 11th Gen Intel I7, 64gb RAM, Windows 11 Home 23H2

    • #2335096

      Open a PowerShell window.
      Type: dir C:\MyDir -Attribute d -Recurse

      This will list all directories and you can then cut and paste. If the list is too long, add a pipe to the command to send it to a file.
      Type: dir C:\MyDir -Attribute d -Recurse | out-file c:\temp\dir.txt

      cheers, Paul

    • #2335107

      Or you could use this powershell:

      $x = (Get-ChildItem -path "G:\BEKDocs" -directory -recurse -depth 2).FullName | Sort
      Set-Clipboard -Value $x
      

      Notes:

      • -Path – sets the base path, i.e. top directory/folder.
      • -Recurse parameter to have the code look at all levels below the specified path level.
      • -Depth – can be used to control how far down the chain -Recurse works.
      • Pipe output to Sort ( | Sort ) to get your directories in sorted order.

      Example output:

      G:\BEKDocs\2020 Tax Statements
      G:\BEKDocs\Access
      G:\BEKDocs\Access\Access Documenter
      G:\BEKDocs\Access\Articles
      G:\BEKDocs\Access\Code to Test
      G:\BEKDocs\Access\Documentation
      G:\BEKDocs\Access\Exported Modules
      G:\BEKDocs\Access\VBA
      G:\BEKDocs\Access\Working Backups
      G:\BEKDocs\Batch
      G:\BEKDocs\Batch\BackupTasks
      G:\BEKDocs\BTB
      G:\BEKDocs\BTB\Home Mgmt
      G:\BEKDocs\BTB\Image and Video Tools
      G:\BEKDocs\BTB\Maintanence
      G:\BEKDocs\BTB\Maintanence\Anti-Malware
      G:\BEKDocs\BTB\Maintanence\Backup Tasks
      G:\BEKDocs\BTB\Maintanence\System Information
      G:\BEKDocs\BTB\Maintanence\Tuning Utilities
      G:\BEKDocs\BTB\Office Tools
      G:\BEKDocs\BTB\PowerShell
      G:\BEKDocs\BTB\PowerShell\Resources
      G:\BEKDocs\BTB\PowerShell\Utilities
      G:\BEKDocs\BTB\Tips Docs
      ...
      

      HTH 😎

      May the Forces of good computing be with you!

      RG

      PowerShell & VBA Rule!
      Computer Specs

      1 user thanked author for this post.
    Viewing 2 reply threads
    Reply To: Copying Folder Names Into Excel

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: