I have a text file with thousands of lines, containing both directory paths and file paths. I would like to loop through each line of the text file and remove any lines containing a directory path, and keep all lines containing a file path. An example of two lines (one directory, and one path from the text file):
exampleDirectoryPath/tags/10.0.0.8/tools/
exampleFilePath/tags/10.0.0.8/tools/hello.txt
So far, to loop through the text file, I have:
foreach ($line in [System.IO.File]::ReadLines("file.txt")) {
if ($line -match ".*/.*$") {
$line
}
}
Goal output:
exampleFilePath/tags/10.0.0.8/tools/hello.txt
Note: I do not want to hardcode file extensions. There are thousands of files to traverse and I dont know what extensions are present, so I would like to return all of them.