First, let's presume you're running Linux for what follows.
1. You're going to want to be familiar with both file(1) and find(1). File(1) is pretty
straightforward, but be aware that its heuristics for file type detection vary in accuracy.
If you're not find-literate, then at least get used to this construct:
find /foo/bar -name "*.jpg" -print | sort -u > /tmp/files.jpg
which will recursively search directory /foo/bar for all files suffixed ".jpg" and dump a sorted list of them into /tmp/files.jpg and this one:
find /foo/bar -type f -print | sort -u > /tmp/files.all
which will search the same directory, but will return a list of all (plain) files, that is,
things which are not directories, devices, sockets, etc., sorted and dumped into file /tmp/files.all.
(Note that the method by which find traverses filesystem trees won't yield sorted output, hence the
need to pipe these through sort.)
2. You now have (a) a list of all jpg files and (b) a list of all files. (I picked jpg arbitrarily
to illustrate the process, by the way.) You can now generate a list of all files that are NOT
jpg with this:
comm -13 /tmp/files.jpg /tmp/files.all > /tmp/files.all2l
The point of this exercise is that you can now repeat steps 1-2 with .gif, .mpg,
etc., as you deal with each file type and reduce the remaining list to those awaiting
your attention. /tmp/files.all3, /tmp/files.all4, etc. will each be smaller and eventually,
if you deal with all files, /tmp/files.allX will be zero-length. Note that not all files
have suffixes, of course -- and those without will likely be the ones requiring the most
manual effort. If you want to know which suffixes are most numerous, something like
sed -e "s/.*\.//" /tmp/files.all | sort | uniq -c | sort -n
will give you a rough idea.
3. Now then...you'll need some tools for dealing with each file type. The first tool
I'd use is stat(1), to check sizes for plausability. Then things like jpeginfo(1), mp3val(1),
tidy(1), will be some help, but of course you'll need to distinguish between "error message
emitted because file is corrupt" and "error message emitted because file has minor
issues...that it had BEFORE this episode". You may need to check the Ubuntu repository
for tools you don't have; you may need to do some searching on the web for "Linux tool to check PDF integrity) and similar.
4. If you have backups of any kind and can restore them, then you could try using sum(1)
to compare checksums pre- and post-incident. This is a filetype-invariant method, which
is good because it lets you skip the above...but bad because all it wll tell you is "different",
not "mildly damaged" or "horribly corrupted" or something in between.
5. I would recommend against deleting anything at this point. Instead, move it to
secondary storage, like an external drive. I don't have a specific reason for advising this,
other than "many years of experience doing partially-manual, partially-automated things like
this and a recognition that sometimes errors in the methodology...or fatigue introduced by
the tedium of executing it...lead to mistakes".
6. Good luck.