Hi All
I have a little script (see below) which should rename all files and directories which match the pattern "bb". The problem however is that the script fails to rename some of the later directories as the script has already renamed some of the earlier directories which these directories live in making the paths invalid, therefore not being able to rename the directory. Is there a way to make the script rename all the files and directories on one level, and then to go into the next level etc etc. {In order to keep the paths valid}? Hope this makes sence?
Thanks!
Something like doing a find . print rename?
#!/bin/ksh
for f in $(find . -name "*bb*" -print); do
mv $f $(echo $f | sed 's!bb!aaa!'); done
I have a little script (see below) which should rename all files and directories which match the pattern "bb". The problem however is that the script fails to rename some of the later directories as the script has already renamed some of the earlier directories which these directories live in making the paths invalid, therefore not being able to rename the directory. Is there a way to make the script rename all the files and directories on one level, and then to go into the next level etc etc. {In order to keep the paths valid}? Hope this makes sence?
Thanks!
Something like doing a find . print rename?
#!/bin/ksh
for f in $(find . -name "*bb*" -print); do
mv $f $(echo $f | sed 's!bb!aaa!'); done