# tn.sh 20250105

progid="newimgs"
dttm=`date "+%Y%m%d_%H%M%S"`
ipath="newimgs"
htpath="."
htmlfile="$htpath/stl2025.html"
htmfil="$htpath/stl2025.htm"


if [ "$1" == "" ]; then
	echo "progid=$progid dttm=$dttm ipath=$ipath htpath=$htpath "
	echo "htmlfile=$htmlfile htmfil=$htmfil"
	echo "$progid vi	# vi $htmlfile"
	echo "$progid ls	# list newimgs"
	echo "$progid view	# preview newimgs"
	echo "$progid tn	# create thumbnails "
	echo "$progid scpi	# scp images"
	echo "$progid scph	# scp stl2025.htm*"
	echo "$progid clear	# clear $ipath"
	exit
	fi

if [ "$1" == "vi" ]; then
	if [ ! -f $htmlfile ]; then
		echo "$progid NOTFOUND htmlfile=$htmlfile"
		exit
		fi

	echo "vi $htmlfile"
	vi $htmlfile
	if [ "$1" == "go" ]; then
		echo "cp $htmlfile $htmfil"
		cp $htmlfile $htmfil
		fi

	exit
	fi


if [ "$1" == "scp" ] || [ "$1" == "scpi" ] || [ "$1" == "scp_i" ] || [ "$1" == "scp_imgs" ]; then
 	echo "cp $ipath/music*.* $tpath/imgs"
 	echo "cp $ipath/tn/tn_music*.* $tpath/imgs/tn"
 	if [ "$2" == "go" ]; then
 		cp $ipath/music*.* $tpath/imgs
 		cp $ipath/tn/tn_music*.* $tpath/imgs/tn
 		fi
 
 	echo "scp $ipath/music*.* konet@ka2:/Volumes/ka2tbr1/ht/stl/imgs"
 	echo "scp $ipath/tn/tn_music*.* konet@ka2:/Volumes/ka2tbr1/ht/stl/imgs/tn"
 	if [ "$2" == "go" ]; then
 		scp $ipath/music*.* konet@ka2:/Volumes/ka2tbr1/ht/stl/imgs
 		scp $ipath/tn/tn_music*.* konet@ka2:/Volumes/ka2tbr1/ht/stl/imgs/tn
 		fi
 	
 	echo "scp -P 2250 $ipath/music*.* kozerus@ko0.us:~/public_html/stl/imgs"
 	echo "scp -P 2250 $ipath/tn/tn_music*.* kozerus@ko0.us:~/public_html/stl/imgs/tn"
 	if [ "$2" == "go" ]; then
 		scp -P 2250 $ipath/music*.* kozerus@ko0.us:~/public_html/stl/imgs
 		scp -P 2250 $ipath/tn/tn_music*.* kozerus@ko0.us:~/public_html/stl/imgs/tn
 		fi
 
 	echo "scp -P 2250 $ipath/music*.* kotwous@ko2.us:~/public_html/stl/imgs"
 	echo "scp -P 2250 $ipath/tn/tn_music*.* kotwous@ko2.us:~/public_html/stl/imgs/tn"
 	if [ "$2" == "go" ]; then
 		scp -P 2250 $ipath/music*.* kotwous@ko2.us:~/public_html/stl/imgs
 		scp -P 2250 $ipath/tn/tn_music*.* kotwous@ko2.us:~/public_html/stl/imgs/tn
 		fi
	exit
 	fi
 
 if  [ "$1" == "scp" ] || [ "$1" == "scph" ] || [ "$1" == "scp_h" ] || [ "$1" == "scp_htm" ]; then
 	echo "scp $ipath/stl2025.htm* konet@ka2:/Volumes/ka2tbr1/ht/stl/"
 	if [ "$2" == "go" ]; then
 		scp $htpath/stl2025.htm* konet@ka2:/Volumes/ka2tbr1/ht/stl/
 		fi
 
 	echo "scp -P 2250 $ipath/stl2025.htm* kozerus@ko0.us:~/public_html/stl/"
 	if [ "$2" == "go" ]; then
 		scp -P 2250 $htpath/stl2025.htm* kozerus@ko0.us:~/public_html/stl/
 		fi
 
 	echo "scp -P 2250 $htpath/stl2025.htm* kotwous@ko2.us:~/public_html/stl"
 	if [ "$2" == "go" ]; then
 		scp -P 2250 $htpath/stl2025.htm* kotwous@ko2.us:~/public_html/stl
 		fi
 	exit
 	fi
 

 if [ "$1" == "preview" ] || [ "$1" == "pre" ] || [ "$1" == "view" ] || [ "$1" == "p" ]; then
	echo "open $ipath -a preview.app"
	open $ipath -a preview.app
	exit
	fi

 if [ "$1" == "thumbnails" ] || [ "$1" == "tn" ]; then
 	imgs=`ls $ipath/music_*.png`
 	echo "imgs=$imgs"
 
 	j=0; k=0;
 	for img in $imgs; do
 		let j=j+1;
 	
 		if [ ! -f $img ]; then
 			echo "$j NOTFOUND_IMG img=$img"
 			continue;
 		else
 			echo "$j ___FOUND_IMG img=$img"
 			fi
 	
 		tn="$ipath/tn/tn_$img"
 		if [ ! -f $tn ]; then
 			echo "$j NOTFOUND_TN tn=$tn"
 			echo "magick $img -resize 100x $tn"
 			magick $img -resize 100x $tn
 		else
 			echo "$j ___FOUND_TN tn=$tn"
 			fi
 		done
 	exit
 	fi

 if [ "$1" == "clear" ] || [ "$1" == "clr" ] || [ "$1" == "c" ]; then
 	echo "rm $ipath/music_*.*"
 	if [ "$2" == "go" ]; then
 		rm $ipath/music_*.*
 		fi
 
 	echo "rm $ipath/tn/tn_music_*.*"	
 	if [ "$2" == "go" ]; then
 		rm $ipath/tn/tn_music_*.*
 		fi
 	exit
 	fi
 
 if [ "$1" == "list" ] || [ "$1" == "ls" ]; then
 	echo "ls -lat $ipath/snap_*.*"
 	ls -lat $ipath/snap_*.*
 
 	echo "ls -lat $ipath/music*.*"
 	ls -lat $ipath/music*.*

 	echo "ls -lat $ipath/tn/tn_music*.*"
 	ls -lat $ipath/tn/tn_music*.*
 	exit
 	fi


	echo "$progid $dttm UNSUPPORTED COMMAND"
