'Delete folder which has "[" and "'" using powershell
I want to delete folders using powershell. here is the foldername
C:\File\Coastal [new]
C:\File_new\Coastal.[new]
C:\File\Russia`s.Book
C:\File_new\Russia`s Book
It looks like ' and [] making the problem. I tried following command:
Get-ChildItem "C:\File\" | Where{$_.Name -Match "Coastal[\s\.][new]"} | Remove-Item -recurse -Force -Verbose
Get-ChildItem "C:\File_new\" | Where{$_.Name -Match "Coastal[\s\.][new]"} | Remove-Item -recurse -Force -Verbose
Get-ChildItem "C:\File\" | Where{$_.Name -Match "Russia`s[\s\.]Book"} | Remove-Item -recurse -Force -Verbose
Get-ChildItem "C:\File_new\" | Where{$_.Name -Match "Russia`s[\s\.]Book"} | Remove-Item -recurse -Force -Verbose
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|