To recover specific file types, first see what's there. Tested on OS X:
file --mime -b /media/Daten/FOUND.*/*.CHK | sort | uniq
application/octet-stream; charset=binary
application/ogg; charset=binary
application/pdf; charset=binary
application/zip; charset=binary
audio/x-wav; charset=binary
image/jpeg; charset=binary
image/png; charset=binary
video/3gpp; charset=binary
Then, for the types you want to keep:
mkdir /tmp/renamed
for f in /media/Daten/FOUND.*/*.CHK
do file --mime $f \
| perl -n -e \
'/^([^.]*).*(3gpp|jpeg|ogg|png|wav)/ && print "$1.CHK /tmp/renamed/$1.$2\n"' \
| xargs cp
done
This uses file --mime
(or file -I
, or file -i
on Linux) to determine the MIME type, then passes the line with both the filename and the MIME type to Perl, which uses a regular expression to capture the base name (like FILE0001
) and the file type (like jpeg
) and prints a line like FILE0001.CHK /tmp/renamed/FILE0001.jpeg
. Finally, that line is passed to cp
.
(The \
continues a single-line command on the next line.)