Writing file names from a loop to a text file

$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. } 

I need to write the file name to a text file in a loop, but I'm not sure how to do this.

In the end, I will read the text file and look for the file names in excel. But now I have to write the .txt file first.

+4
source share
1 answer

I tested this and it worked for me:

 Get-childitem -path "C:\" -recurse -name | out-file C:\Output.txt 
+11
source

Source: https://habr.com/ru/post/1491514/


All Articles