4

Actually learned how to obtain a directory list by looking here. Now that I've updated Windows 10 on my PC laptop, all I find is something called Powershell. There is no command prompt anymore and I have tried to click the "turn off" button for replacing cmd with powershell, but no luck. Well, there is in the Windows-start-right-click, but it opens the command prompt for the computer and I don't know how to get it to identify the folder I need contents to. I am NOT a computer geek. I do NOT understand computer language. I know just enough to get myself in trouble.

Could someone PLEASE tell me how to get a directory list, with or without subdirectories) of any given file folder?

I used to highlight the folder, shift+rightclick, open command prompt and simply "dir /b > dirlist.txt" and the txt file would pop into the folder. I would open it and copy/paste into whatever format I needed. (usually excel or Google sheet) I cannot figure out what to do now.

Again, if you can tell me how to get from users\owner> to, say my "music" folder or any other folder, in this case "01 waw ct" or whatever and then the directory, I'd be good to go. What I really need to someone to please walk me through this. Hold my hand.

enter image description here

enter image description here

2
  • There's a walkthrough for getting that context menu option back here: windowscentral.com/…, apart from that you can use the cd command to get to a particular path.
    – Bob
    Jun 6, 2017 at 4:02
  • It's better not to ask multiple questions in one -- if you can split off the "re-add 'open command prompt here'" and "how do I navigate to a directory in cmd" into their own questions, I'd be happy to answer them with more depth. Though I suspect duplicate questions exist.
    – Bob
    Jun 6, 2017 at 4:05

2 Answers 2

9

The direct equivalent of that command in PowerShell would be dir -n > dirlist.txt.

The long (canonical) form of the command is Get-ChildItem -Name > dirlist.txt.

If you want to include subdirectories, that's dir -n -r > dirlist.txt and Get-ChildItem -Name -Recurse > dirlist.txt respectively.


dir in PowerShell is simply another name for Get-ChildItem, but unfortunately has different option names (-n vs /b) compared to cmd's dir command of the same name.

5
  • dir is cmd's internal command, so powershell can't have it. You can only call cmd /c dir /b from powershell
    – phuclv
    Jun 6, 2017 at 5:51
  • 3
    @LưuVĩnhPhúc PowerShell has an equivalent command, which also has an alias named dir. Did you even try what I posted in the answer? dir -n in PS does more or less the same as dir /b in cmd.
    – Bob
    Jun 6, 2017 at 6:04
  • 3
    In no way, shape or form did I ever claim that PowerShell has cmd's dir. It has a command named dir, its own command in fact. Just as cmd does not have PowerShell's dir.
    – Bob
    Jun 6, 2017 at 6:05
  • Bob, I used the dir -n > dirlist.txt in the PowerShell window! Got my list. Thank YOU! Now, when I try to put in Get-ChildItem -Name > dirlist.txt and click enter, I get this result. 'Get-ChildItem' is not recognized as an internal or external command, operable program or batch file. Am I missing a step, for example, should I be putting something other than "name"?
    – MamaCoop
    Jun 10, 2017 at 4:18
  • @MamaCoop Get-ChildItem only exists in PowerShell. There, dir is a shortcut to it, but it needs -n to get just the name. In cmd, Get-ChildItem does not exist and you only have dir (which requires /d as in your question, in cmd).
    – Bob
    Jun 10, 2017 at 14:04
0

Do you see that menu option, "Open Power_S_hell window here"? Well, you can select that, and get one of those blue-windowed PowerShell windows.

Then, instead of running:

dir /b optional-target > output.txt

You can run this:

cmd
dir /b optional-target > output.txt
exit

Yes, the process is longer. That's the downside. The upsides are that it's an easy workaround, and this process lets you do the same things, in the same way, that you did with the traditional DOS-like command prompt. (Also, having PowreShell run CMD is a technique that ought to work on basically any Windows 10 computer, not just the ones where you've taken the time to re-add a desirable menu option to a context menu.)

When you run "cmd", you'll notice the command prompt will stop saying "PS " at the start of your prompt. That is how you can tell that the computer is ready to accept the traditional-style syntax. Since your command prompt will technically be using CMD, you won't have Powershell trying to insist on you using new parameters/options, and you won't need to worry about PowerShell doing screwy stuff with unescaped commas and quotation marks (until you run the first exit command, which leaves CMD and goes back to PowerShell).

3
  • Bob's comments (posted directly under the question, not in an answer) are probably worth checking out as well. I'm not trying to convince you that the process I just gave you is the best answer. What's best for you will likely depend on you. I'm just sought to nicely provide another option that you can easily check out. Make sure to see those comments by Bob for other options that you might, or might not, like better.
    – TOOGAM
    Jun 6, 2017 at 4:44
  • Thank you TOOGAM. I am seriously computer language illiterate. I did try Bob's answer and got the result I wanted, but wanted to try yours as well. Yes, I get the blue window. Unfortunately, I'm not doing something right as I'm not getting the result. You have "optional-target" italicized.That indicates to me that something else should be there? Am I correct? And do I literally type cmd dir.... exit
    – MamaCoop
    Jun 10, 2017 at 4:17
  • Yes, you literally type cmd, and press Enter. Then you literally type the command that starts with dir, and press Enter. Then you literally type Exit and press Enter. (You can then type Exit and press Enter again.) If you want to specify a target, like showing Thur*.* (all files that start with "Thur"), then you can replace optional-target with Thur*.*. However, the reason I called that part optional-target is because it is entirely optional, so you can just leave that part off entirely (like you may have done before).
    – TOOGAM
    Jun 10, 2017 at 9:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .