I can't recursively remove the pyc files from my Python project.
Here is the project:
Directory: C:\Users\jk025523\projects\ex47 Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 10/07/2016 01:52 bin d----- 10/07/2016 01:52 docs d----- 10/07/2016 01:52 ex47 d----- 10/07/2016 01:52 tests -a---- 09/07/2016 21:02 521 setup.py
There are indeed some pyc files inside the tests directory:
Directory: C:\Users\jk025523\projects\ex47\tests Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 09/07/2016 21:28 180 ex47_tests.py -a---- 09/07/2016 21:28 721 NAME_tests.pyc -a---- 05/07/2016 10:52 0 __init__.py -a---- 05/07/2016 11:37 140 __init__.pyc
However when I enter this command in PowerShell to remove all the pyc files:
find . -name "*.pyc" -exec rm -rf {}
PowerShell outputs this error:
FIND: Parameter format not correct
Anybody know how I can remove all the pyc files from this Python project?
The command you're trying to use is the Linux/Unix find
command, which doesn't work on Windows (unless you have something like Cygwin installed, which I don't recommend). Windows has a command with the same name, but different functionality (works more like grep
). PowerShell does not have a find
cmdlet or alias. You'd do recursive deletion of files with a particular extension like this in PowerShell:
Get-ChildItem -Filter '*.pyc' -Force -Recurse | Remove-Item -Force