Notepad++ new file names
Solution 1
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.
Solution 2
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
Related videos on Youtube
vt.
Updated on September 18, 2022Comments
-
vt. over 1 year
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.
-
Joshua Nurczyk almost 11 yearsIs this for use with the AutoSave plugin or something similar?
-
Raystafarian almost 11 yearssublimetext saves sessions
-
vt. almost 11 yearsYes, for use with autosave. I am not interested in sublimetext, thanks. Notepad++ saves sessions too, just doesn't assign unique filenames.
-
-
Shekhar almost 11 yearsaah, 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.
-
vt. almost 11 yearsI created it. Didn't even think of that originally.
-
Shekhar almost 11 yearshey great job, I think you should publish a link to your plugin here and mark it as the asnwer
-
mwoliver almost 9 yearsAs 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.
-
vt. about 7 yearsGreat. I modified condition to: notepad.getBufferFilename(args["bufferID"])[0:4] == 'new ': and filename: newFilename = ('%s\\%s.txt' % (os.environ['TEMP'], d_string)) Also put this to startup.py