Hide media files from Android media scanners

By default Android will scan your phones memory for any audio, video and pictures and add them to the media player/gallery by default. There are many reasons why this could be annoying. First there might be applications that use audio files (say a gps program). If the developer was inexperienced and/or lazy (and lets face it – most mobile developers at the moment are) no steps were taken to hide these files from the media scanner and they will show up in your music player. You might also have pictures/videos that you would not like to show up in the gallery. There exists a simple mechanism in Android to prevent this and it’s very similar to the way the robots.txt file works to control search engine spidering on websites (you can see where Google got the idea :P ).

Simply create a blank file and call it .nomedia. Whatever directory this file is placed into will indicated to the Android media scanner that any media files inside this directory should not be indexed and left alone.

You can do this on the phone via Astro (or a similar file manager) or a terminal app (just do ‘touch .nomedia‘ – touch is a unix command that will create the specified file, but not actually populate it with any content).

You can also do this via your computer:

Windows - notepad, save as [all file types] .nomedia;
Linux/Mac et al – Use any file editor, file manager or the ‘touch’ command via the terminal).

If you are a developer – please be responsible and ensure that this file exists in any asset containing folder for your project :)

Nokia – Please learn from this example since this was one of the most irritating parts of my whole Nokia experience :(

This entry was posted in Android, Cool Stuff, Tips and tagged , , . Bookmark the permalink.

17 Responses to Hide media files from Android media scanners

  1. Rahul says:

    This trick is simply amazing… Totally appreciate the author for putting it on web. Loved it.

  2. Pingback: Stock Gallery App?... - Android Forums

  3. Jorge González says:

    It works!!, thanks. Simply, Fast and Easy

  4. prashant says:

    How do we create a ‘file’? Only option available is create new folder.

  5. raj says:

    There is an easy way to hide files. First you need to install ES file explorer which is free app an d using the same browse the file you need to hide. Only thing you need to do is rename the file and simply put dot(.) before the file name. Done.!! This file will be hide from galleries and media payers and there is also an option to sow hidden file in ES file explorer. Hope this will helps someone.

    • Owen says:

      This may break other applications using those directories. For example a TV Guide app storing channel logos but not wanting to show these logos in Gallery. You can just create the .nomedia file with ES Explorer without breaking other functionnality.

  6. enderle says:

    Doesn’t seem to work on the Asus Padfone

  7. Spacescape says:

    SIMPLEST SOLUTION:
    Just add a ‘dot’ (.) in the very beginning of the folder-name. (myfolder -> .myfolder) It works fine on my Galaxy Note. Excludes all mediafiles in folder plus subfolders from being indexed in “Gallery”, “videos” etc…

  8. Anon says:

    Looks like the .nomedia file covers all subdirectories too.

  9. CaptainBub says:

    How do I get the effect OTHER THAN rebooting?

  10. CaptainBub says:

    How can I add one to each and EVERY subdirectory on my sdcard? Manually is not an option that interests me. What lines would need be entered in a (b)ash script?

  11. Richard says:

    Useful, thanks

  12. shane says:

    @erin
    Enable your file manager to show hidden files, then delete the .nomedia file. The . in front of the filename tells the OS that this is a hidden file.

  13. erin says:

    How do you reverse the .nomedia effect? Id like to remove it, an email would be helpful

    • Anders Dahlqvist says:

      To create .nomedia files in bash/ash:

      cd to the directory

      find . -type d -exec touch {}\.nomedia \;

      To reverse:

      find . -name .nomedia -exec rm {} \;

      • masayume says:

        Why?? Why would you do it in such a complicated way?? The first command doesnt even make sence – your already in the directory and you run a find command for a directory just to execute a touch command – the first part doesnt even do anything.

        cd directory
        touch .nomedia
        rm .nomedia

        Why confuse inexperienced users??

        • Paul Hedderly says:

          Unfortunately some inexperienced users can’t even be bothered to read but confuse others by making false statements…

          A previous poster asked how to put no media commands in all directories on the SD card – this is what that command does – It descends into a tree of directories and puts nomedia files in all of them – exactly what a previous poster asked for.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>