[ale] Renaming many files (prefix-trim)
Yu, Jerry
zyu at ptek.com
Wed Jun 28 17:42:12 EDT 2000
if it is fixed number for everybody, then something like this will do.
Assume you want it cut the first 2 characters, thus cut -c3- to keep the
3rd character and anythinga after.
for name in *.*
do
test "$name" = "*.*" && continue
newName=`echo $name | cut -c3-`
if [ -n "$newName" ]
then
mv $name $newName || echo "[$name] failed to rename to $newName"
else
echo "[$name] newName too short!!!!"
fi
done
On Wed, 28 Jun 2000, Kenneth W Cochran wrote:
#Hi guys,
#
#I have another shell-question...
#
#I would like to rename some files, effectively "trimming" the
#1st x number of characters from the filenames.
#
#I'd kinda like to do this with Bourne Shell, but Perl may be better.
#I'm checking books (still learning this) but I'm open to suggestions. :)
#
#-kc
#--
#To unsubscribe: mail majordomo at ale.org with "unsubscribe ale" in message body.
#
Jerry Yu mailto: z.yu at ptek.com
Systems Engineer https://punch/~zyu
PTEK Holdings, Inc. +1-404-262-8544 (O)
--
To unsubscribe: mail majordomo at ale.org with "unsubscribe ale" in message body.
More information about the Ale
mailing list