OrderedFiles.py is more sensible as a WindowCommand, and I've *tidied *the code a little.
from os import path
from operator import itemgetter
from datetime import datetime
def run(self, index):
OF = OrderedFilesCommand
OF.file_views = ]
win = self.window
for vw in win.views():
head, tail = path.split(vw.file_name())
modified = path.getmtime(vw.file_name())
OF.file_views.append((tail, vw, modified))
if index == 0: # sort by file name (case-insensitive)
OF.file_views.sort(key = lambda (tail, _, Doh): tail.lower())
win.show_quick_panel([x for (x, y, z) in OF.file_views], self.on_chosen)
else: # sort by modified date (index == 2)
OF.file_views.sort(key = itemgetter(2))
(datetime.fromtimestamp(z)).strftime("%d-%m-%y %H:%M ") + x \
for (x, y, z) in OF.file_views], self.on_chosen)
def on_chosen(self, index):
if index != -1:
No previous poster has come back about this, so I've no idea if anyone is finding it useful (I am )
I was thinking it's (probably) possible to expand it such that typing a single number will jump to that (numbered) file: '(1) somefile.ext'. But having more than 10 files open might make it a little cumbersome.. But still, you could just type a second number . A more complex solution would be to have a 'key' letter(s) highlighted (I believe? this is possible in the quick panel..) to cause the file to be focused.
But I won't bother unless someone expresses an interest . Andy.