Jump to content

Windows 10 - Basic Command Prompt Question

When I use the command prompt to create a text file list of the contents of a folder there will be dates to the left and file names to the right. Example:

 

04/17/2018  10:14 PM    <DIR>   Smile.jpg

I just want the names of the files, NOT the date or <DIR> text. 

Is there a way to quickly copy/paste ONLY the file names from Windows Notepad or is there another command prompt that will generate ONLY file names and NOT dates <DIR> text? 

Thanks

Link to comment
https://linustechtips.com/topic/917763-windows-10-basic-command-prompt-question/
Share on other sites

Link to post
Share on other sites

Use dir /B before the >out.txt parameter. The >>out.txt redirects the output to a file, so whatever the previous command outputs will be put there including all verbosity. Luckily, dir has a /B switch that strips all of the information you said you didn't want, so that's all you need.

 

Example:

 

C:\>dir C:\Users\Vectraat\Desktop /B >>C:\Users\Vectraat\Documents\desktop.txt

 

Would put a completely verbose-free version of the file listing of your desktop, into a text file in your documents folder.

 

If you want filenames only that don't include paths, you'll need to call the dir command from the directory the files are contained in.

 

Hope that helps :)

Link to post
Share on other sites

1 hour ago, Tabs said:

Use dir /B before the >out.txt parameter. The >>out.txt redirects the output to a file, so whatever the previous command outputs will be put there including all verbosity. Luckily, dir has a /B switch that strips all of the information you said you didn't want, so that's all you need.

 

Example:

 

C:\>dir C:\Users\Vectraat\Desktop /B >>C:\Users\Vectraat\Documents\desktop.txt

 

Would put a completely verbose-free version of the file listing of your desktop, into a text file in your documents folder.

 

If you want filenames only that don't include paths, you'll need to call the dir command from the directory the files are contained in.

 

Hope that helps :)

Yep, that worked, thanks. Just typing Dir /B >VectraatFile.txt stripped the date AND directories from the .txt file. It's strange because I could've sworn I saw someone type Dir without the "/B" in Windows 7 and they never generated times/dirs, just the file names. I guess Windows 10 changed something to the command prompt?

Link to post
Share on other sites

Nope, must have just missed the /b (or they had an alias). The dir command is pretty archaic now, and hasn't had an update in many, many years - the version in win7 is the same as in win10 and operates the same as it did as far back as windows 2000 - possibly older.

 

Most of the command line functionality of Windows since late vista/early Win7 has moved towards Powershell and everything else has been depreciated.

 

Edit: Also, no problem, glad to help. :)

Link to post
Share on other sites

10 minutes ago, Tabs said:

Nope, must have just missed the /b (or they had an alias). The dir command is pretty archaic now, and hasn't had an update in many, many years - the version in win7 is the same as in win10 and operates the same as it did as far back as windows 2000 - possibly older.

 

Most of the command line functionality of Windows since late vista/early Win7 has moved towards Powershell and everything else has been depreciated.

 

Edit: Also, no problem, glad to help. :)

Is there utility in learning more about Command Prompt or is my time better spent else where? Initially, I only wanted to learn the basics because there were certain things I wanted to be able to do with MAME (game emulation) that couldn't be done without the use of the command prompt. 

Being able to generate a list of files in a directory is pretty handy at times. Quicker than typing or copy/pasting. So for myself and my needs I'd say that is useful. 

Is there anything else useful about Command Prompt and is this somewhat similar to learning how to program? 

Link to post
Share on other sites

4 minutes ago, Vectraat said:

Is there utility in learning more about Command Prompt or is my time better spent else where? Initially, I only wanted to learn the basics because there were certain things I wanted to be able to do with MAME (game emulation) that couldn't be done without the use of the command prompt. 

Being able to generate a list of files in a directory is pretty handy at times. Quicker than typing or copy/pasting. So for myself and my needs I'd say that is useful. 

Is there anything else useful about Command Prompt and is this somewhat similar to learning how to program? 

I would love to send you to some resources on how to learn what kind of things you can do with the command prompt but realistically...  The command prompt has been dead and/or dying for a very long time. If you're truly wanting to learn, it would be a disservice to teach you it.

 

It's in the process of being replaced by a really cool object-based command line system called Powershell, and I would highly recommend you check out Microsoft's own documentation in that regard, starting with this - https://mva.microsoft.com/en-us/training-courses/getting-started-with-powershell-3-0-jump-start-8276

 

Microsoft's own documentation is incredibly informative (if a bit boring at times) but Powershell is so ridiculously powerful that if you get to grips with it, you'll be set for the foreseeable future in doing whatever you want in Windows. It's also a demonstrably important skill in any kind of future IT work involving Windows administration, so if you ever want to get into the field it's a massive plus for any future employer.

Link to post
Share on other sites

Tabs is right,

 

Heres a starter pack for what you asked in PS

first two do the dame thing, but one is the lazy way of typing it.

3rd get all preoperties of the objects

4th shows only files that end with .jpg

5th shows only .jpg that contian the text "Dank Memes". 

There is always better more elegant ways to do things with scripting, but its actually easy to get it to do what you want without much effort and some Google.

Get-ChildItem -path .\ | Select-Object name
ls | select name

Get-ChildItem * | select *
Get-ChildItem * | where Extension -eq .jpg
Get-ChildItem * | where-object Extension -eq .jpg | where BaseName -like "*Dank Memes*" | select name

 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×