简体   繁体   中英

how to retreive a list of filenames from a directory without the file extension

I have a powershell command I use frequently to obtain a list of files in a specific directory

dir -name > filenames.txt

Output

filename.pdf filename2.pdf

This however creates a list with the file extensions. Is there a simple way I can run a single line command that returns the file names not including the file extensions.

I would like the result to be like the following

filename filename2

Just use:

(Get-ChildItem | Select -Expand BaseName) >filenames.txt

Basename property gets the file name without extension.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM