> web-file-viewer.sourceforge.net > scripts

<= Parent directory | Home Directory revision date: 2008/08/11 14:19:39 UTC.
 

Show/Download this file as plain text ]

#!/bin/sh

# stamp

# 20020122 PixEye@bigfoot.com	Creation

nbps=1				# Number of wanted parameters (without options)
cmd=`basename $0`		# Command name
usage="Usage: $cmd [-h]"	# Help message
usage=$usage"\n\tDisplay this help message.\n"
usage=$usage"\nUsage: $cmd [-t <tic>] [-m <mogrify options>] [-n <basename>] "
usage=$usage"[-c|-T]\n\t\t[-w] <file> [...]"
usage=$usage"\n\tRename files with date and hour."
usage=$usage"\n\t-c enable copy mode (safer)."
usage=$usage"\n\t-w avoid to delete the Write permissions."
usage=$usage"\n\t-T enable Test mode (no rename, only display)."

mode="mv" ; tic="c" ; sufx="pix" ; mogo="" ; delWrite="true"
if test `uname -s` != "HP-UX" ; then e="-e" ; fi
while [ "$#" -ge 1 ] ; do			# Read options:
	case "$1" in
		"-t") if [ "$#" -ge 2 ] ; then tic="$2" ; shift 2 ; fi ;;
		"-m") if [ "$#" -ge 2 ] ; then mogo="$2" ; shift 2 ; fi ;;
		"-n") if [ "$#" -ge 2 ] ; then sufx="$2" ; shift 2 ; fi ;;
		"-c") mode="cp -p" ; shift ;;	# copy mode
		"-T") mode="echo" ; shift ;;	# Test mode (print only)
		"-p") echo "The -p option became -n !" 1>&2 ; exit 1 ;;
		"-w") delWrite="false" ; shift ;; # Keep Write permissions
		*) break;
	esac
done

if [ "$1" = "-h" -o "$#" -lt "$nbps" ] ; then	# Check parameters number
	echo $e $usage 1>&2 ; exit 2		# Display help and exit
fi

if [ "$#" -gt 0 ] ; then files=$* ; else files=s*.jpg ; fi # Files list

ext="jpg" ; counter=1
mogp=`which mogrify|grep -v "no mogrify in"`
#date=`date +"%Y%m%d"`
y=`date +"%Y"`
#month=`date +"%m"`
/bin/ls -l -- $files|while read line
do
	set 1 $line ; shift 6
	if [ "$#" -eq 4 ] ; then
		month="$1" ; d="$2" ; shift
		if [ "$d" -le 9 ] ; then d="0$d" ; fi
	else
		y=`echo $1|cut -c-4`
		m=`echo $1|cut -c6-7`
		d=`echo $1|cut -c9-`
		month=$m
	fi
	time="$2" ; file="$3"

	chmod a-x "$file"
	if $delWrite ; then chmod go-w "$file" ; fi

	time=`echo $time|sed -e 's/://g'`
	case $month in
		Jan|jan) m="01" ;;
		Feb|fév) m="02" ;;
		Mar|mar) m="03" ;;
		Apr|avr) m="04" ;;
		May|mai) m="05" ;;
		Jun|jun) m="06" ;;
		Jul|jui) m="07" ;;
		Aug|aoû) m="08" ;;
		Sep|sep) m="09" ;;
		Oct|oct) m="10" ;;
		Nov|nov) m="11" ;;
		Dec|déc) m="12" ;;
		*)	 m="$month" ;;
	esac

	date="$y$m$d"
	rep=`dirname "$file"`
	base=`basename "$file"`
	ext=`echo $base|sed -e 's/^[^\.]*\.//'`
	chmod a+r "$file"
	if [ "$tic" = c ] ; then	# New file name:
		if [ "$counter" -le 9 ] ; then zero="0" ; else zero="" ; fi
		stamp="_$zero$counter" ; else stamp="$tic"
	fi
	nfn="$rep/$date-$time${stamp}_$sufx.$ext"

	# Display and action:
	echo "$file -> $nfn"
	if test "$mode" != echo ; then
		$mode -i -- "$file" "$nfn" || exit $?
		if test -n "$mogo" -a -n "$mogp" ; then
			mogrify $mogo "$nfn"
		fi
	fi

	counter=`expr $counter + 1`
done

exit 0		# When all happened right


mkgallery.sh
(5k)

mkthumbs.sh
(1k)

snap_ren.sh
(2k)

web-files-viewer_php.txt
(19k)

wfvgrc_php.txt
(1k)

Powered by Web File Viewer W3C XHTML 1.1 certified W3C CSS valid WFV revision date: 2005/12/04 11:43:26 UTC.