The command I've used:
find . -type d -name "__pycache__" -exec rm -r {} +
Explains:
First finds all __pycache__
folders in current directory.
Execute rm -r {} +
to delete each folder at step above ({}
signify for placeholder and +
to end the command)
Edited 1:
I'm using Linux, to reuse the command I've added the line below to the ~/.bashrc
file
alias rm-pycache='find . -type d -name "__pycache__" -exec rm -r {} +'
Edited 2:
If you're using VS Code, you don't need to remove __pycache__
manually.
You can add the snippet below to settings.json
file. After that, VS Code will hide all __pycache__
folders for you
"files.exclude": {
"**/__pycache__": true
}
Hope it helps !!!