Quote:
Originally Posted by kmkocot
Hi all,
I have a directory with around 5,000 files that do not have an extension (or any regularity that I could take advantage of using rename). I want to append the extension ".ab1" to the name of each of these files. Can anyone help me out?
Example filenames:
Pl_xlvO_36A01
Pl_xlvO_35H12
Pl_xlvO_35H07
Thanks!
Kevin
|
Do it this way:
Code:
path="/path/of/interest"
find $path -type f | grep -iPv "\.ab1$" | while read filepath
do
mv $filepath $filepath.ab1
done
The trick in a situation like this is to avoid renaming already-renamed files. That's what the grep filter does -- it eliminates files that are already renamed.
WARNING: Test this script on a copied sample of the files in a separate, disposable directory before applying it to the original files. I say this because, for reasons that should be obvious, I haven't tested it.