![](/img/trans.png)
[英]How to retrieve the full file extension from filenames with 2+ dots in CMD?
[英]how to retreive a list of filenames from a directory without the file extension
我有一個我經常使用的 powershell 命令來獲取特定目錄中的文件列表
dir -name > 文件名.txt
輸出
文件名.pdf 文件名2.pdf
但是,這會創建一個帶有文件擴展名的列表。 有沒有一種簡單的方法可以運行單行命令,該命令返回不包括文件擴展名的文件名。
我希望結果如下
文件名文件名2
只需使用:
(Get-ChildItem | Select -Expand BaseName) >filenames.txt
Basename
屬性獲取不帶擴展名的文件名。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.