Plan 9 from Bell Labs’s /usr/web/sources/contrib/boyd/sys/src/cmd/rni

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/bin/sh
#
# rni files ...
#
# Rename image files
#
#
# Boyd Roberts <boyd@fr.inter.net>
# April 2000
#

myname="`basename \"$0\"`"
view='xv'

case $# in
0)
	echo "usage: $myname files ..." 1>&2
	exit 1
	;;
esac

for i
do
	# get extension

	x="`expr \"$i\" : '.*\.\(.*\)'`"

	# view image

	if $view "$i"
	then
		echo -n "New name for '$i'? "

		if read n
		then
			case "$n" in
			'')
				# no
				continue
				;;

			*.*)
				# new name with extension
				;;

			*)
				# tack on extension
				n="$n.$x"
				;;
			esac

			mv "$i" "$n"
				
		else
			exit 0
		fi
	fi
done

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.