Get the proper suffix depending on the file type.
gurus.knugum at gmail.com
Thu Jan 5 17:21:27 UTC 2012
2012/1/5 Johnny Rosenberg <gurus.knugum at gmail.com>:
> 2012/1/4 Peng Yu <pengyu.ut at gmail.com>:
>> The command 'file' print human readable file format. But I need to get
>> the correct suffixes for some files with incorrect suffixes. I could
>> parse the output of 'file' and then map to the correct suffixes. But
>> I'm wondering if there is any more automatic way of doing so? Thanks!
> I made a script the other day, that copies image files from the Opera
> cache folder (Opera the web browser). All the files there are named
> something like oprXXXXX.tmp where each X can be an upper case letter
> or a number. Since I only copied images I used Image Magick (identify)
> instead of file, but I guess file could be used as well, if the code
> is adjusted accordingly.
I'm not sure it was obvious why I wrote this at all, so just in case
I'll add that al the files in that folder had the suffix ”tmp”, but
they are actually images, html pages, flash videos and more. What I
wanted to do was to detect all the images files and copy them to
another folder. So it's not exactly the same as you want to do, but
parts of it are.
More information about the ubuntu-users