Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

2 Answers

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. –  Shakehar 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 –  Shakehar Jul 17 '13 at 23:20
add comment

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
add comment

Your Answer

 
discard

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.