Problem, searching through a large amount of directories/files to clean up files that are older than 10 years old. Some folders and files have [ ] in the name. i.e.
C:\Temp\Test_Old_Folder\Test [TEST]\Test [TEST].txt
C:\Temp\Test_Old_Folder\Test [TEST]\Test - Copy.txt
I have a script that will check the last access date and if the access date is 10 years of more old it will delete the files. Currently we are using shadow copies, so if the user needs it back within the next 2 years they can go back and find the files.
foreach ($File in $FileList) {
Remove-Item -Path $File.FilePath -Force
}
I have tried to rename the files/folder that contain the [ ] to something else, however, that has not worked either. I can manually delete the files/folder, however, if there are hundreds of them in multiple folders spread all over the file server this is a waste of man hours. Is there a way to comment out the [ ]. I know is some languages you can use a single ` to make the following character be read as a string and not an operation or whatever you want to call it.
Any help would be greatly appreciated.