How to regenerate a specific thumbnail in Nautilus?

According to the freedesktop documentation Thumbnail Managing Standard . You can force nautilus to recreate the thumbnail if the mtime (modification time) in the thumbnail is lower than the mtime in the original file.

  1. Detect Modifications

One important thing is to assure that the thumbnail image displays the same information than the original, only in a downscaled version. To make this possible we use the modification time stored in the required 'Thumb::MTime' key and check if it's equal the current modification time of the original. If not we must recreate the thumbnail.

Example 2. Algorithm to check for modification.

if (file.mtime != thumb.MTime) { recreate_thumbnail (); }

It is not sufficient to do a file.mtime > thumb.MTime check. If the user moves >another file over the original, where the mtime changes but is in fact lower than >the thumbnail stored mtime, we won't recognize this modification.

In order to achieve this... you can try with a little Nautilus-Script to set the mtime in the original file to the current time with the touch command.

1) Creating the script. Open a Terminal window Ctrl+Alt+T and type:

For Ubuntu 12.04 & 12.10

  • nano ~/.gnome2/nautilus-scripts/Regenerate-Thumbnail

For Ubuntu 13.04 & above

  • nano ~/.local/share/nautilus/scripts/Regenerate-Thumbnail

2) The content of the script.

#!/bin/bash

BAKIFS=$IFS
IFS=$'\n'

for FILE in $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS; do
      touch -m "$FILE"
done

IFS=$BAKIFS

To save the changes in nano.. Ctrl+O,Enter then Ctrl+X.

3) To make the script executable.

For Ubuntu 12.04 & 12.10

  • chmod +x ~/.gnome2/nautilus-scripts/Regenerate-Thumbnail

For Ubuntu 13.04 & above

  • chmod +x ~/.local/share/nautilus/scripts/Regenerate-Thumbnail

4) To test the script you can open nautilus, select a file(s), right click and go to Scripts > Regenerate-Thumbnail.

enter image description here

enter image description here

enter image description here

enter image description here

Hope this helps.


I know this is an old question, but... sometime the thumbnails get stuck and no trick with touch -m or mv makes it regenerate.

Write this simple script (thanks to this answer), let's call it find-gnome-thumbnail:

#! /bin/bash 
#
fn=$(echo -n "$1" | md5sum | awk '{print $1}')
find $HOME/.cache/ -name "$fn*" 2> /dev/null

and feed it with the canonical name of the file of which you want to determine the thumbnail location. The better way to do this is to select the file in nautilus, do ctrlC, and in a terminal write find-gnome-thumbnail ' (with the space and the opening single quote) and after that shiftctrlV; add the closing quote and you'll have something like this:

 % ./find-gnome-thumbnail 'file:///home/romano/tmp/0101_IM_3026506.pdf' 
/home/romano/.cache/thumbnails/large/d090cf90d2ac3f8127f62043f06b66df.png

Now you can delete the offending thumbnail and it will be regenerated (press F5 if it does not happen alone). The copy-paste trick take care of strange chars conversions:

 % ./find-gnome-thumbnail 'file:///home/romano/tmp/lalla%20(copy).pdf'
 /home/romano/.cache/thumbnails/large/28864dd40fab6d4982e1b103365574da.png

Sometime the script fails if you rename the file with mv, I do not know why --- but it's ok most of the times. Also deleting the thumbnail manually does not regenerate it immediately --- again, I am at a loss here.


I have a script that I use (author unknown) called Auto Thumbnailer which works fine for this. I got it in a package of scripts that I obtained here.

and installed it in /.local/share/nautilus/scripts

Edit: Here's the script I used (extracted from the deb package).

#!/bin/sh

#Dialog box to choose thumb's size
SIZE=`zenity --list --title="Choose the thumbnail's size" --radiolist --column="Check" --column="Size" "" "100X100" "" "320x240" "" "640x480" "" "800x600" "" "1024x768"`
if [ "${SIZE}" == "" ]; then    
zenity --error --text="Size not defined by user.
Please choose a size to use. "
exit 1
fi

# How many files to make the progress bar
PROGRESS=0
NUMBER_OF_FILES=`find -iname "*.jpg" -maxdepth 1 | wc -l`
let "INCREMENT=100/$NUMBER_OF_FILES"

mkdir -p thumbnails

# Creating thumbnails. Specific work on picture should be add there as convert's option
(for i in *.jpg *.JPG; do
echo "$PROGRESS";
echo "# Resizing $i";
convert -resize "${SIZE}"  -bordercolor black -quality 90 "${i}" thumbnails/"${i}"
let "PROGRESS+=$INCREMENT"
done
) | zenity  --progress --title "$Creating thumbnails..." --percentage=0

#process png
# How many files to make the progress bar
PROGRESS=0
NUMBER_OF_FILES=`find -iname "*.png" -maxdepth 1 | wc -l`
let "INCREMENT=100/$NUMBER_OF_FILES"

mkdir -p thumbnails

# Creating thumbnails. Specific work on picture should be add there as convert's option
(for i in *.png *.PNG; do
echo "$PROGRESS";
echo "# Resizing $i";
convert -resize "${SIZE}"  -bordercolor black -quality 90 "${i}"         thumbnails/"${i}"
let "PROGRESS+=$INCREMENT"
done
) | zenity  --progress --title "$Creating thumbnails..." --percentage=0

Note that this script was 5 years old when I found it and could certainly use some updating today.

Edit Jan 20 2021: This failed miserably on Ubuntu 18.04. I was able to refresh failed thumbnails by deleting the ~/.cache/thumbnails/fail directory