Renaming files in subdirectories
Hi,
I'm currently trying to make a script to rename all the files with one provided file extension to a second provided file extension. I've achieved this by commanding "sh newext doc txt" with the following which works perfectly:
#!/bin/sh
for f in *$1;
do
mv "$f" "`basename "$f" $1`$2";
done;
However, I'd like to be able to modify what I've written so far, so that I can choose whether to convert file extensions in a subdirectory or not. For example, I could enter "sh newext -r doc txt" and the subdirectory's files would also be affected by my script, or enter "sh newext -n doc txt" which would only affect the directory I'm in.
I searched the forums and found a few things that I'm now looking in to, but anything else would be much appreciated. Thanks.
|