# BASH Script to Rename Multiple Files

1. Nov 24, 2008

### minger

Hi guys, this should be a pretty easy thing to do, I'm just not familiar enough with bash shell scripting to do it.

I have a bunch of files named

flow0001.fast
flow0002.fast
....
flow0024.fast

and I would like to remove one zero from the name so:
flow001.fast
flow002.fast
...
flow024.fast

I could do it by hand, but I may have to do it a few times, so a script would be nice. I know the number of files at all times, so I don't need IFs or any searches for the number of files to change.

thanks a lot,

2. Nov 24, 2008

### D H

Staff Emeritus
Try something on the lines of
Code (Text):
for (( i=1 ; i<$N ; i++ )) do of=printf 'flow%04d.fast'$i
nf=printf 'flow%03d.fast' $i mv$of \$nf
done

3. Nov 25, 2008

### minger

Is there any chance you can explain the code a little? I'm not sure I understand it properly