Removes bot pics from your files and logs statements
This is a simple python script to remove pictograms (emoji,
symbols, and Unicode pictographic characters) from text files.
It assumes you have python3 (v3.6+) installed and command python3.
remove-pictograms.py- Python scripttest/test-pictograms.txt- Test file with 135 pictogramstest/test-pictograms.txt- Backup used to replace whack'd test filetest/restore-test.sh- shell script to restore whack'd test file
# Make executable (first time only)
chmod +x remove-pictograms.py
# Always do 'verbose' dry run to see will be changed
python3 remove-pictograms.py -v --dry-run "*.txt"
# Display verbose output
python3 remove-pictograms.py --verbose "*.txt"
# Use a path spec, to remove pictograms in specified path
python3 remove-pictograms.py "*.txt" "docs/*.md"
The Python script is char-code, unicode accurate:
- Uses
unicodedatamodule for precise Unicode character classification - Checks Unicode categories (So, Sk) and names containing keywords
- Covers specific Unicode blocks for emoji and symbols
- Conservative and accurate detection which can be viewed before changing
- Supports wildcards and recursive patterns
# Remove pictograms from all text files
python3 remove-pictograms.py "*.txt"
# Remove from markdown files in docs/
python3 remove-pictograms.py "docs/*.md"
# Remove from nested directories
python3 remove-pictograms.py "src/**/*.js"
# Dry run first to see what would change
python3 remove-pictograms.py --dry-run "*.txt"- Python 3.6+
- No additional dependencies (imports are standard python libs)
- Backup or --dry-run - This script makes irreversible text file changes, so always backup files in the pathspec, or preview the results in
--dry-runmode until satisfied. - Check your Pathspec - This is designed for text files, but it will 'remove-pictograms' any file - including binary files - in the pathspec! Check all the files impacted, to ensure NO unexpected files are mistakenly targeted by your pathspec !
- Check Results - The script only removes, and does not replace pictograms. If you have files logging a lone pictogram for any reason (e.g.
log.success(`✅`)), you should consider adapting script to replace, rather than remove, certain chars.