[英]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我有一个我经常使用的 powershell 命令来获取特定目录中的文件列表
dir -name > filenames.txt dir -name > 文件名.txt
Output输出
filename.pdf filename2.pdf文件名.pdf 文件名2.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文件名文件名2
Just use:只需使用:
(Get-ChildItem | Select -Expand BaseName) >filenames.txt
Basename
property gets the file name without extension. Basename
属性获取不带扩展名的文件名。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.