Search code examples
windowsgitspecial-characters

How to delete a file/directory with '$' in the name using powershell or cmd


I accidentally created a directory (programmatically) whose name starts with $. All efforts to delete it have failed, via powershell, cmd, explorer. It doesn't want to recognize the $ as part of the name, and probably isn't interpreting it as it either. I've seen some info on removing files/dirs with leading/trailing dots or whitespace, but that doesn't seem to work in this case. Has anyone else seen this? I doubt i can delete the repo i'm working in because of this. Thanks.


Solution

  • Try rm '$name' -recurse -force in powershell, and rd /q /s $name in cmd, and rm -rf '$name' in bash.