I like to personalize my Nautilus icons from folders and files with images.

enter image description here

The problem is that all the times that I format my computer I lose all the icons that I've worked so hard to organize. So, is there a way to backup all these personalized "thumbnails" that I've been using on Nautilus? Where are they stored? Can I backup the configuration from a specific folder and then replicate it on a different computer that uses Nautilus and has the same folder structure?

  • Please mention your OS version, desktop environment, and version of Nautilus. Nautilus has had features added/removed rather frequently. – DK Bose May 16 '18 at 4:21
  • @DKBose I'm running Ubuntu 16.04 with Unity and the version of Nautilus is 3.14.3. – Rafael Muynarsk May 16 '18 at 12:21
  • Possible duplicate of How can I programmatically change a file's icon? – d1bro May 17 '18 at 1:13
  • @db429: While that does explain quite a few things about the topic in question a way to back-up custom file icons is not among them – David Foerster May 17 '18 at 13:29

I've ended up creating a script to solve my problem. That's not exactly a backup solution but it works for me.




# Generate a recursive list of all folders and files inside the folder $folderToBeUpdated
ls -R "$folderToBeUpdated" | awk '
NF&&f{ print s"/"$0 }' > $file

# Start inserting icons dynamically on files and folders
while IFS='' read -r line || [[ -n "$line" ]]; do
   folderName="$(basename "${line}")"
   pathName="$(dirname "${line}")"
   if [ -f "$iconsFolder"/"$folderName".png ]   
   gvfs-set-attribute -t string "$pathName/$folderName" metadata::custom-icon "file://$iconsFolder/$folderName.png"
done < $file

The idea of this script is that we need to give it the path of two folders:

  1. The path of a folder full of icons (iconsFolder)
  2. The path of the folder we wish to put icons recursively (folderToBeUpdated)

The script will check the icons and the folders with the same name and then it will insert icons on specific folders in case that's true, e.g a folder inside folderToBeUpdated is called example and I have an icon called example.png inside my iconsFolder, so the icon example.png will be inserted as the folder example's icon (if the name isn't the same the script won't do anything).

PS: It's necessary to press F5 after running the script in order to see the icons.

That's just a functional script but it turns out to be useful because I can easily replicate my icons on different computers. In any case, if anyone knows a way to do backups of icons in a more convenient way, feel free to write a new answer or give suggestions in the comments.

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.