I have a list of filenames in a text file like this:
f1.txt
f2
f3.jpg
How do I delete everything else from a folder except these files in Powershell?
Pseudo-code:
- Read the text file line-by-line
- Create a list of filenames
- Recurse folder and its subfolders
- If filename is not in list, delete it.