将文件名从循环文件写入文本文件

时间:2013-07-15 20:41:59

标签: powershell

$fileEntries = [IO.Directory]::GetFiles("C:\Users\U0146121\Desktop\Example Data"); #where the file is located.
foreach($fileName in $fileEntries) 
{ 
 #write the file name to a text file.  
}  

我需要将文件名写入循环中的文本文件,但我不知道该怎么做。

最终我将读取文本文件并在excel中搜索文件名。但是现在我必须首先编写.txt文件。

1 个答案:

答案 0 :(得分:13)

我对此进行了测试,它对我有用:

Get-childitem -path "C:\" -recurse -name | out-file C:\Output.txt
相关问题