Best way to rename sequentially 36 files, starting from the 4th file

Hi all,

I’m not a scripter and I’ll happy if I can receive some tips for my trouble…

I’ve to rename a bunch of folder that contains each one 36 files numbered sequentially. I want to:

  • Use as prefix of the containing files of each folder the name of the folder.
  • Starting to rename each files sequentially from _01 to _36.
  • the first file to rename is not the first original but the fourth.

Any tips?

thanks a lot!

[code]#!/bin/bash

IFS=$‘\n’
for d in find /some/directory -type d -not -name ".*"; do
cd “$d”
i=0
for f in *; do
i=$(($i+1))
[[ $i -le 3 ]] && continue
mv “$f” "${d}_"printf %02d $i
done
done[/code]