I am configuring a new laptop, and I want to do it a little more cleanly than my last few migrations to a new machine. Rather than simply copying over all my files, I am being quite selective. As I work my way through some archives, I am learning to purge some unneeded files such as .pyc files from code directories.
# Remove all .pyc files from a directory, and all its subdirectories: # Find only files ending in .pyc, then pipe them to the rm command. find . -type f -name "*.pyc" | xargs rm -frv # Remove all virtualenv directories from a directory tree: find . -type d -name "venv" | xargs rm -frv
In doing this, one source directory went from ~8000 files to ~800 files, and from ~50MB to ~3MB. This also makes me rethink my backup script. I think my next backup script will exclude these files in the first place.