Hi
I have a txt containing a list of document names (docx) For example:
newdoc2023.docx
document_34.docx
filedocument.docx
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
C:\Doc\archive\2021\save\filedocument.docx
Many thanks
from a filename to file paths
- Simon Sheppard
- Posts: 192
- Joined: 2021-Jul-10, 7:46 pm
- Contact:
Re: from a filename to file paths
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}
Re: from a filename to file paths
sorry, this is a .bat? Sorry I m not expert, tell me where I must put the string
- Simon Sheppard
- Posts: 192
- Joined: 2021-Jul-10, 7:46 pm
- Contact:
Re: from a filename to file paths
PowerShell can be run from a .PS1 script or directly at the command line, just adjust the filenames to match what you have.
Re: from a filename to file paths
I have create the.ps1 file but don't work. I see only the terminal interfare with a led
I have change it to:
CD E:\
$files = get-content list.txt
foreach ($file in $files) {dir $file -recurse | select -expandProperty fullname | out-file -append -encoding utf8 E:\result.txt}
The source is E:
The file with the list is named "list.txt"
I have change it to:
CD E:\
$files = get-content list.txt
foreach ($file in $files) {dir $file -recurse | select -expandProperty fullname | out-file -append -encoding utf8 E:\result.txt}
The source is E:
The file with the list is named "list.txt"
- Simon Sheppard
- Posts: 192
- Joined: 2021-Jul-10, 7:46 pm
- Contact:
Re: from a filename to file paths
See How-to: Run a PowerShell script
https://ss64.com/ps/syntax-run.html
https://ss64.com/ps/syntax-run.html
Re: from a filename to file paths
the script run but don't work