Various scripts in various languages.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.1 KiB

#, Copyright © 2010 Matteo Cypriani
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
# for more details.
# This script converts all HTML (.html and .htm) files in the current
# directory into text files (.txt). For each HTML file, it verifies
# that the text file, if it exists, is older; if the text file is more
# recent, nothing is done.
# Look for html2text
if ! which html2text >/dev/null ; then
echo "Error! html2text not found within the PATH." >&2
exit 1
for HTML in *.html *.htm ; do
# Avoid to create "*.html.txt" and "*.html.txt" if there is no
# .html or no .htm files
if [ ! -f "$HTML" ] ; then
TXT=$(basename "$HTML" .html).txt
# Is the .html file more recent than the .txt ?
if [ -f "$TXT" ] && [ "$HTML" -ot "$TXT" ] ; then
# Convert the file
echo "$HTML --> $TXT"
html2text -nobs -o "$TXT" "$HTML"