How do I delete the contents of multiple folders except for specific files?
For example, I have multiple folders which contain the same files, as below:
I want to delete all files from each folder, except for File1 and File3. Can I do this with Powershell?
Thank Crom! You guys are awesome!! We've figured out how to delete the files. However, I forgot to mention that I need to delete other folders also.
For example, here is what my folder structure looks like.
C:\Users\myname\Desktop\project1\english\folder1\file1 C:\Users\myname\Desktop\project1\english\folder1\file2 C:\Users\myname\Desktop\project1\english\folder1\file3 C:\Users\myname\Desktop\project1\english\folder2\file4 C:\Users\myname\Desktop\project1\english\folder2\file5 C:\Users\myname\Desktop\project1\chinese\folder1\file1 C:\Users\myname\Desktop\project1\chinese\folder1\file2 C:\Users\myname\Desktop\project1\chinese\folder1\file2 C:\Users\myname\Desktop\project1\chinese\folder2\file4 C:\Users\myname\Desktop\project1\chinese\folder2\file5
Goal: Delete everything except the following: