Super User is a question and answer site for computer enthusiasts and power users. 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 way to have Notepad++ generate new file names with the current date?

Like this: YYYY_MM_DD_new1.txt or similar. Currently it just names them: new1, new2, etc.

Date in the file name will work great with autosave, there will be no name conflicts after NPP restart.

All I want is a way to store sessions between restarts. I want to autosave even the unnamed files.

Thanks.

share|improve this question
    
Is this for use with the AutoSave plugin or something similar? – Joshua Nurczyk Jul 17 '13 at 15:52
    
sublimetext saves sessions – Raystafarian Jul 17 '13 at 15:59
    
Yes, for use with autosave. I am not interested in sublimetext, thanks. Notepad++ saves sessions too, just doesn't assign unique filenames. – vt. Jul 17 '13 at 17:36
up vote 0 down vote accepted

Notepad ++ has a plugin Autosave2 that saves your documents with a time stamp in the file name like this :

ToDo.txt.2013-04-19 10.13.09

ToDo.txt.2013-04-19 10.14.09

ToDo.txt.2013-04-19 10.15.09

share|improve this answer
    
From the Autosave2's page: The above settings will create a new backupfile for "ToDo.txt" in D:\NPP_\Backups as follows (if the text has changed within 1 minute): ToDo.txt.2013-04-19 10.13.09 ToDo.txt.2013-04-19 10.14.09 ToDo.txt.2013-04-19 10.15.09. I don't want extra copies of the file though, I want the file itself to have a unique name. – vt. Jul 17 '13 at 17:34
    
aah, my bad. But your requirements seem to specific, I guess you will have to get someone to make a plugin that does it for you. – Shekhar Jul 17 '13 at 18:05
    
Ah. Thanks for the idea. – vt. Jul 17 '13 at 20:47
1  
I created it. Didn't even think of that originally. – vt. Jul 17 '13 at 21:33
1  
hey great job, I think you should publish a link to your plugin here and mark it as the asnwer – Shekhar Jul 17 '13 at 23:20

I just did this using the Python Script plugin for NPP...

notepad.clearCallbacks([NOTIFICATION.BUFFERACTIVATED])
def my_callback(args):
    if notepad.getBufferFilename(args["bufferID"]) == "new  1":
        fmt = '%Y%m%d%H%M%S'
        d = datetime.datetime.now()
        d_string = d.strftime(fmt)
        notepad.saveAs('X:\\Documents\\Notepad++_autosave\\%s.txt' % d_string)
notepad.callback(my_callback, [NOTIFICATION.BUFFERACTIVATED])

With the above code, as soon as I type Ctrl+N, the new file is created and saved instantly with the name formatted as defined in 'fmt' above. The path for the file to be saved is defined above as well; change it to suit your environment.

share|improve this answer
    
As of v6.7.9.2 of NPP, the single-quote for 'new 1' in the 'if' test fails, but replacing the single-quote with double-quote restored functionality. – mwoliver Jul 13 '15 at 20:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .