简体   繁体   English

如何从没有文件扩展名的目录中检索文件名列表

[英]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.

相关问题 如何从CMD中带有2个以上点的文件名中检索完整的文件扩展名? - How to retrieve the full file extension from filenames with 2+ dots in CMD? R:获取目录中所有文件的短文件名(文件名)列表 - R: get a list of short file names (filenames) for all files in a directory 如何在 CPP 的给定目录中列出 UTF 编码的文件名? - How to list UTF encoded filenames in a given directory in CPP? 如何使用具有文件名列表作为输入的txt文件从FTP服务器下载这些文件? - How to use a txt file that has a list of filenames as input, to download those files from FTP server? PowerShell Output 文本文件的特定扩展名的文件名 - PowerShell Output Filenames of a Specific Extension to a Text File 如何使用批处理脚本创建没有文件类型扩展名的文件夹名称并移入创建的子目录? - How to create folder name without extension of file type using batch script and move in created sub directory? 如何在不更改目录的情况下从父目录执行文件 - How execute file from parent directory without changing directories 批处理脚本列出文件扩展名指定的目录中的文件 - Batch script to list files in directory given by file extension 使用脚本如何创建包含目录C:\\ sample \\中所有文件名的文本文件? - Using a script how do I create a text file that contains all of the filenames in a directory C:\sample\? 使用特定文件名批量迭代文件列表 - Batch iteration of file list using specific filenames
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM