2

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.

YSN
  • 2,349

3 Answers3

2

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.

Pascal
  • 516
1

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 = datetime.datetime.now()
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))

else:
    for _file in sys.argv[1:]:
        newfile = prefix+_file
        print("New file: {0}".format(newfile))
        shutil.move(_file, newfile)
0

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

RolandiXor
  • 51,541