Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a simple way (maybe a script), to automatically insert the current date into the filename of a newly created document either in nautilus or in Libreoffice?

A function like that would be useful for me, since I produce a lot of documents and sort them by making their names start with the date of their creation.

share|improve this question
up vote 1 down vote accepted

Put this code into a file (e.g. add_date) move it to the ~/.gnome2/nautilus-script directory. Perhaps you need to add execute permissin (chmod a+x add_date). If you rightclick on a file in nautilus, you can append the date before the file name like in How can I write nautilus scripts in Python. The format can be changed in the row beginning with prefix = (strftime formatting)

#!/usr/bin/env python
# coding: utf-8

import sys
import os
import datetime
import shutil

datetime =
prefix = datetime.strftime('%y_%m_%d_%H-%M_')

if len(sys.argv) == 1:
    command = os.path.split(sys.argv[0])[-1]
    print("usage: {0} file...".format(command))

    for _file in sys.argv[1:]:
        newfile = prefix+_file
        print("New file: {0}".format(newfile))
        shutil.move(_file, newfile)
share|improve this answer
Thank you, works like a charm! Great job! – YSN Jul 6 '11 at 1:02

Nautilus-actions or Nautilus scripts may help. You could get something like a "timestamp" command in the contextual menu. Nautilus-actions lets you choose which file types will have the command available.

Nautilus-actions is available in software-center and then in settings menu. Nautilus scripts are those stored in "~/.gnome2/nautilus-script"

Doing so, your files won't be automatically timestamped, but the job will be easier.

share|improve this answer

Unfortunately, no. You can however rename the files using a batch renaming program (those are numerous in the Software Centre).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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