Solved Copy Folder List to Clipboard ?

BuckSkin

New member
Power User
VIP
Local time
2:12 AM
Messages
521
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:

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Dell Optiplex 780m "mini-tower"
OS
Windows 7 Pro x64
CPU
Intel Core Two Duo E8600 3.33 ghz
Motherboard
Whatever DELL put in it
Memory
8GB
Graphics Card(s)
Gigabyte Radeon R7 240
Monitor(s) Displays
HP 2159m
PSU
750 Watt Corsair CX750
Keyboard
Logitech Wireless
Mouse
Logitech Wireless
Browser
Chrome, Firefox, IE
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

Computer type
Laptop
Computer Manufacturer/Model Number
Toshiba Sattelite A665-S6092
OS
Windows 7 Ultimate x64
CPU
Intel Core i7-740QM
Memory
8 GB DDR3
Graphics Card(s)
NVIDIA GeForce 330GT
Screen Resolution
1366x768
Hard Drives
Samsung 840 SSD 500GB
1TB USB3 external HD
Cooling
Coolermaster Notepal U3 notebook cooling pad
Internet Speed
3mbps ASDL
Antivirus
ClamWin 0.98.7
Browser
Opera 12.17 x86 (main), Firefox 38 (sec), IE11 (last resort)
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:

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Dell Optiplex 780m "mini-tower"
OS
Windows 7 Pro x64
CPU
Intel Core Two Duo E8600 3.33 ghz
Motherboard
Whatever DELL put in it
Memory
8GB
Graphics Card(s)
Gigabyte Radeon R7 240
Monitor(s) Displays
HP 2159m
PSU
750 Watt Corsair CX750
Keyboard
Logitech Wireless
Mouse
Logitech Wireless
Browser
Chrome, Firefox, IE
Back
Top