This is a static demo, please compare to the other HTML file in this directory. The colours won't match, but compare what is hilighted. This HTML is ripped off my test site. The links other than attached assets will go to non-existent URL, as you aren't on my network.
#!/bin/bash
# what        : script that replaces dangerous charactors in file names
# author      : owen beresford
# contact     : mf.liamtsaf@margorpnacnewo (spin it around, before you put it down)
# contact URL : www.noonshadow.org.uk
# last edit   : 2/6/04
# licence     : perl second artistic licence
# licence URL : www.noonshadow.org.uk/articles/artistic-licence-2.html
# language    : bash (any recent version)
# version     : 1.1
# depends on  : sed mv ls
# name        : name-strip
# warn        : This is automation, not lobotomy.

if [ "$1" = "-h" -o "$1" = "--help" ]; then
    echo Script that replaces dangerous charactors in file names.
    echo $0' [-h] [directory name] [strict]'
    echo "'strict' is a higher level of paranoia"
    exit 0;
fi

if [ -n "$I_AM_TOO_PARANOID" ]; then
    echo  Punctuation stripper with $* arguments
fi

if [ -n "$1" -a -d "$1" ]; then
    cd $1
fi
if [ -z "$replacement_char" ]; then
    replacement_char="-"
fi

#date +%Y.%m.%d-%H.%M.%S
#date +%s
stupid=""
if [ -n "`ls -al " " 2>/dev/null`" ];then
    echo "Somebody thinks they're soooo clever (file named \" \")."
    mv -- " " file-called-space
fi
for x in `ls -1a `; do
    if [ "$x" = "." -o "$x" = ".." ];then
	continue;
    fi
    if [ "" = "$stupid" ];then
	stupid="$x"
    else
        stupid=`echo $stupid*$x`
    fi	
    if [ -f "$stupid" -a -O "$stupid" ]; then
    	if [ "$2" = "strict" ]; then
	    y=`echo "$stupid" | sed -e 's/[^A-Za-z0-9+_.()-]/'$replacement_char'/g'`
	else
	    y=`echo "$stupid" | sed -e 's/[ \t\"\`:;<>]/'$replacement_char'/g'`
	fi
	if [ $y = "$stupid" ];then
	    if [ -n "$I_AM_TOO_PARANOID" ]; then
		echo No change for $x
	    fi
	else
	    if [ -n "$I_AM_TOO_PARANOID" ]; then
		echo "Pretend to move '$stupid' to '$y' "
	    else
		mv -- "$stupid" $y
	    fi 
	fi
	stupid=""
    elif [ -f "$stupid" ]; then
	stupid=""
    fi	
done



Static demo for Bash hilighting.

RSS. Share: Share this resource on your linked-in account. Share this resource on your twitter account. G+ ­ Follow