I have a bunch of text files in a directory that do not have the .txt extension... what is a god one liner to add the .txt extension to these files but if the files already have and extension of some sort omit those?
cd /path/to/directory
find . -type f -maxdepth 1 ! -name "*\.[0-9A-Za-z]*" -print0| xargs -0 -i{} echo mv {} {}.txt
echo is for a dry run. Remove it to perform the actual operation.
The above assumes "extension of some sort" consisting of a dot "." and any number of alphanumeric characters.
Should you want to test for shorter extensions only please let me know!
find . -type f -maxdepth 1 ! -name "*\.[0-9A-Za-z]*" -print0| xargs -0 -i{} echo mv {} {}.txt
echo is for a dry run. Remove it to perform the actual operation.
The above assumes "extension of some sort" consisting of a dot "." and any number of alphanumeric characters.
Should you want to test for shorter extensions only please let me know!