Page 1 of 1

from a filename to file paths

Posted: 2023-May-15, 8:05 pm
by Lauraq
Hi :)
I have a txt containing a list of document names (docx) For example:


I would need a script that searches the list of names inside a folder (and subfolders) and creates a txt containing the file path
For example:

C:\Doc\Nuova cartella\2023\newdoc2023.docx
C:\Doc\Nuova cartella\2020\base\doc\document_34.docx

Many thanks :)

Re: from a filename to file paths

Posted: 2023-May-30, 11:03 pm
by Simon Sheppard

Code: Select all

CD C:\Doc\
$files = get-content files.txt
foreach ($file in $files) {dir $file -recurse | select -expandProperty fullname | out-file -append -encoding utf8 C:\demo\result.txt}
This is assuming the current directory is the start point for the search.