sanitize

command module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2020 License: MIT Imports: 9 Imported by: 0

README

sanitize

Sanitize a string for use as a filename

Usage: sanitize <input-text>

Examples:

  • sanitize This Is a TEXT --> this-is-a-text
  • sanitize THIS_is a+a-TEXT --> this-is-a-text

Caution: Different input strings can result in identical output.

All punctuation and spaces are converted to single -. No -s are left at the beginning or end of output string. All capital letters are converted to lowercase.

  • sanitize 1 2 3 --> 1-2-3

Numbers are not affected.

  • sanitize Łączność --> lacznosc

Diacritics are converted to their basic letters of the English alphabet.

If punctuation is getting in the way of the shell interpreting input correctly, escape "input" with quotes.

  • sanitize abc; de --> bash throws an error de: command not found
  • sanitize "abc; de" --> abc-de works as expected

san.sh <filenames> is just a wrapper that parses filenames into names and extensions, calls sanitize on both and renames original files (will not overwrite existing files).

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL