Copy Folder List to Clipboard ?


  1. Posts : 514
    Windows 7 Pro x64
       #1

    Copy Folder List to Clipboard ?


    As per HERE, how can I change the provided "command" such that it lists the sub-foldernames contained within the folder and ignores the filenames ?

    As it is given, will it copy both filenames and foldernames to the clipboard or just the filenames ?

    Thanks so much.


    Update: I have played around in command prompt and this command "dir /b |clip" (without quotes) will copy the foldernames while ignoring the filenames; however, they do not paste in order and there really is no rhyme nor reason to the order in which they do paste.
    What "switch" do I need add to get them to paste in the order they are in the folder ?
    Last edited by BuckSkin; 15 Jul 2022 at 03:46.
      My Computer


  2. Posts : 2,468
    Windows 7 Ultimate x64
       #2

    First of all, have a look at the official documentation of the dir command:

    dir | Microsoft Docs

    Now to check your current command, the /b modifier doesn't ignores filenames (both files and folders are shown), just removes the header and all the details, leaving only plain names. Good to get a good listing, not for much more.

    Generally when you don't specify an explicit ordering for the result it's displayed in whatever order the files happen to be in the directory table (which is inaccesible directly) without any logical ordering. There is nothing like "in the order they are in the folder", you ask for what order do you want the results in.

    All in all, I think this is the final command you need:

    Code:
    dir /ad /on /b | clip

    Explanation:
    /ad: Only displays folders, not files.
    /on: Sort by name ascending. Look at the docs for more sorting options.
    /b: Only show names and nothing else.
    | clip: Pipe the output to the clipboard instead of showing in the console.
      My Computer


  3. Posts : 514
    Windows 7 Pro x64
    Thread Starter
       #3

    Alejandro85 said:

    All in all, I think this is the final command you need:
    Thank you so much.

    I will give it a try after while and post back.


    Update:

    I altered the command that How to Geek provided by replacing the last portion with the command that you provided and it works just exactly as I wanted with my folder names listed in filename order.

    It took a couple tries before I got the result I wanted.

    That "%1" is pretty important to include; when I tried it without it, I have no idea just what I copied, but a got about three pages worth of something.

    When I went back and included the "%1", then all worked just as I wanted.

    For anyone who may stumble upon this, here is the command that I entered in the default properties:

    "
    cmd /c dir "%1" /ad /on /b | clip" (less quotes)

    This right-click business didn't quite show up where I expected = if I expand to the folder that I want and right-click the blank area, my command choice does not display; however, if I right-click the root folder that I want to list, my command displays in the menu and works exactly as I wanted.

    Thank you very much for helping me in this.
    Much appreciated.



    For what it's worth, I clicked the "Thank" button and it told me I needed to spread my thanks around; I don't know if it thanked you or not.
    Last edited by BuckSkin; 15 Jul 2022 at 13:02.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 17:41.
Find Us