On Tue, 25 Jun 2002 [EMAIL PROTECTED] wrote:
> I want to rename a bunch of files in one go. After Googling I got this:
>
> $ find -name "*.abc" -exec echo {} {} \; | sed -e "s/\.abc/\.def/" |
> awk �{print $2 " " $1}� | xargs -n 2 -t mv
If this is all you want to do, then this will do it:
for i in *.abc; do mv $i ${i%abc}def; done
but you want to rename
s*.abc to s*.sNN
so, try this:
n=0; for i in *.abc do n=$(($n+1)); mv $i ${i%abc}${${i%${i#?}}$n; done
this is not perfect - you'll get extensions like .s1 - .s9, then .s10 -
.s99 and then .s100 ->
so, if you want better extensions, put the n=$(($n+1)) inside a
condition to decide what it should be.
--
In every non-trivial program there is at least one bug.
-------------------------------------------------------
Sponsored by:
ThinkGeek at http://www.ThinkGeek.com/
_______________________________________________
linux-india-help mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/linux-india-help