Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: renaming with number prefix
- X-seq: zsh-users 1259
- From: Nate Johnston <natej@xxxxxxx>
- To: Sven Guckes <guckes@xxxxxxxxxxxxxxxxx>
- Subject: Re: renaming with number prefix
- Date: Fri, 23 Jan 1998 11:40:00 -0500 (EST)
- Cc: ZShell Users <zsh-users@xxxxxxxxxxxxxxx>
- In-reply-to: <19980123165404.53612@xxxxxxxxxxxxxxxxx>
- Reply-to: Nate Johnston <natej@xxxxxxx>
- Sender: natej@xxxxxxxxxxxxxxxxxxxx
On Fri, 23 Jan 1998, Sven Guckes wrote:
>Problem:
>Rename all files within a directory such that their names
>get a numeral prefix in the default sort order.
>Btw, "leading zeroes" would be a bonus.
An amateur's stab at it (I don't know the extended features of
globbing....I must learn). Again, I beg you to forgive the horrendous
inefficiencies of this approach.
foreach FILE (`ls -1 | cat -b | tr ' ' ':' | tr '\t' ':'`)
NUMBER=`echo $FILE | cut -c 4-6 | tr ':' '0'`
NAME=`echo $FILE | cut -c 8-80`
echo "mv $NAME $NUMBER.$NAME"
end
--N.
--
Nathaniel Johnston
Work: natej@xxxxxxx | Internet Infrastructure Engineering
Solaris System Administrator | MCI Communications Co.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author