Please explain, simply, dir /b > dirlist.txt with powershell

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

2 Answers

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

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

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like