Skip to content

joanatam/remove-pictograms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

remove-pictograms - whack annoying pictograms

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.

Files

  • remove-pictograms.py - Python script
  • test/test-pictograms.txt - Test file with 135 pictograms
  • test/test-pictograms.txt - Backup used to replace whack'd test file
  • test/restore-test.sh - shell script to restore whack'd test file

Usage

Python Script (Recommended Usage)

# 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"

Results

The Python script is char-code, unicode accurate:

  • Uses unicodedata module 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

Examples

# 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"

Requirements

Python Script

  • Python 3.6+
  • No additional dependencies (imports are standard python libs)

Recommended

  • Backup or --dry-run - This script makes irreversible text file changes, so always backup files in the pathspec, or preview the results in --dry-run mode 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.

About

Remove pictograms from text file(s)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors