How do I prevent my Ubuntu 14.10 (now 15.04) from creating and saving thumbnails for a specific folder only?
I want to tell the thumbnailer to skip over that single folder (and subfolders), but for all existing and future user accounts.

I read some answered questions about excluding a specific file type, but I need to exclude files by their location!
What I already tried is to hide the folder (renamed to .foldername), but with no luck. The folder is owned by root, by the way.

  • 6
    Just the start of an idea (and it will work for a single user only): the thumbnails are created, if I understand correctly, by hashing the path and writing a file called [hash].png to a directory .thumbnails/normal/ and/or .thumbnails/large/ in the user's home directory. Your program could perform the same hash and write a zero-byte thumbnail file instead. By any luck, the thumbnailer routine will notice that a thumbnail file already exists and skip thumbnailing your image.
    – Jos
    Mar 20 '15 at 12:54
  • What thumbnailer do you use? Where do you save the thumbnails? Jul 8 '15 at 18:26
  • @daltonfury42 I can't tell you. The situation where I specifically needed this was on an old, now dead laptop. I was running Ubuntu with XFCE there, so I think it was tumbler or however its thumbnailer was called. Anyway, I think if this is possible, it should be a more general solution.
    – Byte Commander
    Jul 9 '15 at 15:26

In addition to @Fabby answer:

  1. Install the package inoticoming

    sudo apt-get install inoticoming
  2. Create wrapper script disable_thumbnails

    # Create the thumbnail filename
    tn_filename=$(echo -n "file://$1/$2" | sed 's/\s/%20/g' | md5sum | awk '{print $1}')
    # Destroy the thumbnail without deleting
    find ~/.cache/thumbnails -type f -name "$tn_filename*" -print0 | while IFS= read -d '' file; do
      echo > "$file"
    exit 0
  3. Make it executable

    chmod +x disable_thumbnails
  4. Kill running processes, if necessary

    killall inoticoming
  5. Watch your folder

    Avoid a trailing / for the folder names

    inoticoming "<path_to_disabled_thumbnail_folder>" <full_path_of_disable_thumbnails_script>  {} "<path_to_disabled_thumbnail_folder>" \;

There is only one problem. The changes are only visible after nautilus -q

Use inoticoming --foreground … to avoid the daemon mode, if you test the script.

  • Okay, the nautilus -q kills the nautilus background process and releases thumbnails cached in memory, I guess. And why is there the \; at the end of the inoticoming command?
    – Byte Commander
    Jul 16 '15 at 13:28
  • @ByteCommander To mask the ; We need the ; in the command and not as delimiter for the next command.
    – A.B.
    Jul 16 '15 at 13:34
  • And what is this about inoticoming --foreground _? What's wrong with daemon mode? I thought it should run automatically in the background. Oh, and how do I set this thing to start automatically?
    – Byte Commander
    Jul 16 '15 at 13:37
  • @ByteCommander To test the script use --foreground
    – A.B.
    Jul 16 '15 at 14:13

To get the file name for the thumbnail, start md5sum for the original file name:

% echo -n "file:///home/user/Pictures/image%201.png" | md5sum
6e1669aea9c118cb2b7ad23fc6646c71  -

% find ~/.cache/thumbnails -type f -name "6e1669aea9c118cb2b7ad23fc6646c71*"

Now remove the read permissions:

chmod -r /home/user/.cache/thumbnails/large/6e1669aea9c118cb2b7ad23fc6646c71.png

Restart nautilus:

nautilus -q

and you will have no thumbnail for /home/user/Pictures/image 1.png.

Now you only have to write a script that scans your particular folders and do the above steps automatically.

Credits :P

  • If you add that script and include a line that overwrites the thumbnail with a 0-byte file, I will be happy! Oh, and you have to tell me (or link) how to get the script to run automatically. Best would be to react on file system events in that folder, if this was possible... I have no idea how to give you that bounty though, I guess @A.B. Has to do that as he offers it...
    – Byte Commander
    Jul 16 '15 at 10:36
  • @ByteCommander something like this?
    – A.B.
    Jul 16 '15 at 10:56
  • @A.B. Yes, looks good. If you would now write another answer with that script and everything together, that would be awesome! :-)
    – Byte Commander
    Jul 16 '15 at 11:13
  • @ByteCommander done :)
    – A.B.
    Jul 16 '15 at 13:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.