Get the proper suffix depending on the file type.

Johnny Rosenberg gurus.knugum at gmail.com
Thu Jan 5 17:23:40 UTC 2012


2012/1/5 Johnny Rosenberg <gurus.knugum at gmail.com>:
> 2012/1/5 Johnny Rosenberg <gurus.knugum at gmail.com>:
>> 2012/1/4 Peng Yu <pengyu.ut at gmail.com>:
>>> Hi,
>>>
>>> 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!
>>>
>>> --
>>> Regards,
>>> Peng
>>
>> 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.
>
>
> Kind regards
>
> Johnny Rosenberg
> ジョニー・ローゼンバーグ

Oh, just forgot to say that if you are not used to write scripts (you
didn't mention anything about it), always test your scripts with dummy
files in dummy folders, in case something is wrong. And always do
backups of important files. Obvious, I know, but still some people
don't.


Kind regards

Johnny Rosenberg
ジョニー・ローゼンバーグ




More information about the ubuntu-users mailing list