3

So, I dragged and dropped multiple files onto notepad++. The files came from different directories and were selected using different criteria.

So, I have many files open in Notepad++. Now I need to have a list of all the open files in another file.

Right now, my only option is to script the decisions used to guide me in selecting the files in the first place. Which is probably the best in the long term, but I wonder if there is a quicky one in Notepad++. Some plugin magic or whatever.

Suggesting another free editor which has this function is a good option too (not that I am going to ditch notepad++, God forbid)

3

Yes, Install Python Script Plugin Plugin Manager.

After installing Python console, toggle the Python console.

Type this in the console:

notepad.getFiles()

to return all open files as a List type:

[('C:\\Users\\ahmed\\Desktop\\1999.txt', 32818504, 0, 0), ('D:\\WORKSPACE\\imza\\e-mail.html', 32721752, 1, 0), ('new  1', 32721944, 0, 1)]

The code below is one-shot command to retrieve the file names, and is suitable for Python Script command line. You can extend it with persistent Python scripts.

fileNames = [n[0] for n in notepad.getFiles()]

How to dump this fileNames to an existing file or newly created file

Current File: Paste this code and hit Enter twice.

for f in fileNames: editor.appendText(f + '\n')

New File Paste this code.

notepad.new() ; for f in fileNames: editor.appendText(f + '\n')

It is also possible dump to an external file, this snippet from http://npppythonscript.sourceforge.net/ is easy to understand even if you are not familiar with Python:

externalFile='_log.log'; console.run('cmd /c ls > "%s"' % externalFile, editor) 

Documentation

Comprehensive documenation is avaible in http://npppythonscript.sourceforge.net/docs/latest/ with Python Primer tutorial.

4

File > Save Session will create a file that has quite a lot of information about what you were doing. It will have a list of all of the open files. You'll have to do a bit of parsing to get just the file names.

  • This is an excellent advice and is good enough for me. – mark Oct 31 '13 at 16:08
  • Still an excellent advice, but I have to accept guneysus's answer - it is the best hands down. – mark Nov 6 '13 at 0:14
1

In windows, if you make a folder on your desktop (etc) called "working set" (or whatever), you can drag a shortcut to the file(s) into this folder instead of dragging them to notepad++.

You can then open them as normal using the file > open dialog: notepad will open the shortcut target. You can open multiple files in one operation this way.

You can also right click the shortcut in explorer and "open with > notepad++" but this will only open a single file rather than a group of them you might have selected.

Note that if you use "send to", instead of "open with" it will open the shortcut itself which is a binary file and not what you want.


You can also save a "session" under the "file menu". This will create an xml file which contains the currently opened files, as well as viewport settings etc. you can reload the session, or you can open and parse the session file to extract the filenames.


Again for windows, if you are scripting the file selection, you can use vbs to create the shortcuts:

 set objWSHShell = CreateObject("WScript.Shell")

' command line arguments
' TODO: error checking
sShortcut = objWSHShell.ExpandEnvironmentStrings(WScript.Arguments.Item(0))
sTargetPath = objWSHShell.ExpandEnvironmentStrings(WScript.Arguments.Item(1))

set objSC = objWSHShell.CreateShortcut(sShortcut) 

objSC.TargetPath = sTargetPath

objSC.Save

Note argument 0 will be the path an name of the shortcut, and argument 1 will be the target of the shortcut (the filename). This can be called using:

cscript create_shortcut.vbs %1 %2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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