====== Automatically assigning extensions to files ====== #recursively find files in current directory that have no extension for i in $(find . -type f ! -name "*.*"); do #guess that extension using file extfile=$(file --extension --brief $i) #select the first extension in the event file spits something weird (e.g. jpeg/jpe/jfif) extawk=$(echo $extfile | awk -F/ '{print $1}') #copy the file to a file appended with the extension guessed from the former commands mv $i $i.$extawk done