Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copying file names to a text file in PowerShell

I've currently got a PowerShell script that copies the file names in a directory to a text file. It excludes .info files from the copy. This is my code as it stands:

Get-ChildItem -Path "C:\Test\" -Recurse -name -exclude '*.info' | out-file C:\Test.txt

I need to dump out a different text file for each individual file it copies the name of, with the name of the text file that of the name it copies.

I've done a lot of reading and still can't seem to find a resolution. How can I fix it?

like image 387
user3586898 Avatar asked Oct 18 '25 15:10

user3586898


1 Answers

Get-ChildItem -Path "D:\Projects" -Recurse -exclude '*.info' | ForEach { [System.IO.File]::WriteAllText("C:\test\"+ $_.Name + ".txt", $_.FullName)}
like image 158
Diligent Key Presser Avatar answered Oct 20 '25 13:10

Diligent Key Presser