Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: renaming with number prefix



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