Results 1 to 5 of 5

Thread: Find files by file type - not file extension

  1. #1
    Join Date
    Jul 2009
    Location
    United States
    Beans
    156
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Find files by file type - not file extension

    I notice that in Nautilus on Ubuntu (specifically 10.10, but I'm sure it could still apply to 12.10) that there is a "Type" column when listing files in the list view. The string displayed there shows the file type of the respective extension. However, if no extension is given on the file it automagically knows what filetype it is and displays it.

    For example if I have a file called "MyFlashVideo" (which is indeed a flash video), then the Type column will display "Flash video" automagically. If I rename if to "MyFlashVideo.txt" it corrects itself incorrectly and calls it a "plain text document".

    Anyway, my question is how I can search my file-system for files without any extensions by their file type. (In a specific example suppose I want to find all the flash videos that don't have extensions on my computer)

    Any help is greatly appreciated!
    1: Win 7 - 2500k - 660ti - 8GB DDR3
    2: Xubuntu - 3570 - 650ti (2GB) - 12GB DDR3
    3: Win 8.1 - Q6600 - 9800 GTX+ - 8GB DDR2
    4: Arch - E7500 - 8800 GT - 6GB DDR2

  2. #2
    Join Date
    Nov 2007
    Location
    NC, USA
    Beans
    829
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Find files by file type - not file extension

    Dunno how to do it in the GUI but on the command line you can use the file command with the --mime-type switch.

    Code:
    man file
    Linux User #460341 || Ubuntu User #19510 || Unanswered Posts Team

  3. #3
    Join Date
    Nov 2012
    Beans
    8

    Re: Find files by file type - not file extension

    Hi,

    I've never tried it, but this:

    http://linux.die.net/man/1/file

    looks like it might work.

    Good Luck,

    Anne

  4. #4
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,499
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Find files by file type - not file extension

    Code:
    find -type f -iregex '^.+/[^./]+$' -exec file '{}' \; | grep -i 'flash video'
    it's recursive and takes a while, so test it in some location with few files first.
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

  5. #5
    Join Date
    Jul 2009
    Location
    United States
    Beans
    156
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Find files by file type - not file extension

    Hey all, thanks for the responses, and thank you Vaphell, your script works well, however searching with grep for something specific as "Flash video" does not work. After looking at what gets dumped without grepping for anything in specific I see that "MPEG" fits the bill for what I'm looking for, as well as "AVI" etc...

    Awesome!
    1: Win 7 - 2500k - 660ti - 8GB DDR3
    2: Xubuntu - 3570 - 650ti (2GB) - 12GB DDR3
    3: Win 8.1 - Q6600 - 9800 GTX+ - 8GB DDR2
    4: Arch - E7500 - 8800 GT - 6GB DDR2

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •