I store my images in this structure:


-foo is optional and a short description of the event.

Sometimes I would like to store a long description for this directory.

I think the answer "You can use programm X for your images" does not help.

I would like to have a solution that works for directories containing text or audio files, too.

Question: How to give a directory a long description? A description which can contain newlines and other characters like a slash?


And you can't simply store text files with descriptions in the directories?

Yes I could do this. But I thought there is already a convention or specification for this.

I would love to see this in nautilus:

  • 01-short-directory-name, Long and verbose Text,
  • 02-short-directory-name, Long and verbose Text2,
  • ...

I could not find a meta-data spec for directories myself.

Needed features

  • Backup with rsync, tar, dropbox or owncloud should work.
  • Text should allow to contain any unicode character.
  • Arbitrary key value mapping (like json)
  • Common solution, not a self made script hack.
  • 4
    And you can't simply store text files with descriptions in the directories? – techraf Aug 9 '16 at 6:52
  • try putting the description between " " so you get YYYY/MM/DD-"first image of the second month of the third year" – patrick Aug 9 '16 at 7:03
  • @techraf I updated the question. Please ask if something is not clear. Thank you. – guettli Aug 9 '16 at 10:16
  • @guettli I have read your question and comments under Rinzwinds answer. This approach is very very troublesome, and especially since you're setting this up for non-technical users, too. I strongly suggest you abandon this idea of having special chars in filename. That said, I can offer the following: How about a right-click option that will display a popup message with description ? – Sergiy Kolodyazhnyy Aug 12 '16 at 19:03

Rinzwind has already presented reasons why slashes and other special characters are not desirable in filenames and directory names. My answer presents a simple workaround via Nautilus scripts.


The following script relies on existence of .directory_description file in each directory ( note the leading dot ). If the file doesn't exist user will be prompted to create one.

Advantages of this approach are:

  1. Simple to use : .directory_description is just text file, therefore simply editable via text editor. It's just right click action, so even non-technical user can use it.

  2. Description is part of directory, so when properly backing up directory ( with inclusion of all files, including the dot files) , the description will be backed up as well.

Obtaining the script

The script is available as part of my github repository as well as below. For those who have git installed, use the following steps in terminal.

  1. cd ~/.local/share/nautilus/scripts
  2. git clone https://github.com/SergKolo/nautilus_scripts

Those who do not have git follow these steps:

  1. copy the source code directly from this answer.
  2. Save the code as ~/.local/share/nautius/scripts/read_dir_description.py file.
  3. Ensure it is executable with chmod +x ~/.local/share/nautius/scripts/read_dir_description.py

Now, every time you right click on directory and go to scripts menu, you will be able to run read_dir_description.py on that directory.

Script source code:

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
Author: Serg Kolo
Date: Aug 16,2016
Written for: http://askubuntu.com/q/809925/295286
import subprocess
import sys
import os.path

def display_file(textfile):
    """ Displays file containing
        directory description if 
        the file exists
                    '--filename=' + textfile

def create_file(textfile):
    """ Creates text file containing
        directory description
        if the description doesn't exist
        err_text = '"This directory doesn\'t have description.' +\
                   'Would you like to create one now?"'
                              '--text=' + err_text
    except subprocess.CalledProcessError:

    # ensure we create the file
    with open(textfile,'w') as text:

        output = subprocess.check_output([
                           '--filename=' + textfile
    except subprocess.CalledProcessError:

    with open(textfile,'w') as text:

def main():

    file_name = '.directory_description'
    directory = os.path.abspath(sys.argv[1])
    file_path = os.path.join(directory, file_name)
    if os.path.isfile(file_path):
        create_file(file_path )

if __name__ == '__main__':

Script in Action

Accessing the script via right click

enter image description here

Dialog notifying that description doesn't exist

enter image description here

Sample directory description

enter image description here

| improve this answer | |
  • Yes, I guess storing the meta data in a file .directory_description works. Sad, that there is no common standard. – guettli Aug 17 '16 at 9:00
  • @guettli there isn't one right now , unfortunatelly, but you could always open feature request for such feature on launchpad page for Nautilus :) – Sergiy Kolodyazhnyy Aug 17 '16 at 9:13
  • 1
    @Serg Nice script. Works in Thunar too. – Panagiotis Tabakis Aug 17 '16 at 21:04
  • 1
    @Serg I could not find a matching page at launchpad. I create an issue here: bugzilla.gnome.org/show_bug.cgi?id=770144 – guettli Aug 22 '16 at 10:10
  • @guettli that's good i guess. Launchpad is here :launchpad.net/nautilus – Sergiy Kolodyazhnyy Aug 22 '16 at 11:24

You could use Extended File Attributes. After installing the package attr you can do e.g. something like this:

setfattr -n user.comment -v "this is a comment" directory_name

and read it with:

getfattr -n user.comment directory_name

According to this site there is a package called eicielwhich integrates in Nautilus.

Slashes and other ASCII characters are not a problem, however other characters can be tricky, see https://unix.stackexchange.com/questions/138768/what-is-this-seemingly-base64-data-set-by-setfattr.

rsync, cp, scpand probably most other standard tools either preserve extended attributes or have an option to preserve it.

| improve this answer | |
  • Big question is, can you add slashes and special characters to it ? Also, is it possible for non-techie users to access those comments in easy maner ? – Sergiy Kolodyazhnyy Aug 17 '16 at 10:43
  • Next question: Do these attributes survive rsync, cp, scp ...? – guettli Aug 17 '16 at 11:21

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.