Originally Posted by kmkocot
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?
Do it this way:
find $path -type f | grep -iPv "\.ab1$" | while read filepath
mv $filepath $filepath.ab1
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.