SelectConsecutive

Title SelectConsecutive
File Name SelectConsecutive.txt
Description Select files with consecutive numbers
Author Vochomurka
Parameters "%P", "%O", "%E"
Plugins Called win, tc, childwin, miscplugin, file
Icon
Version 1.0
Updated on 27.08.2007
args Path, Name, Ext
local Len = length(Name)
local hwnd = win.handle("c=TTOTAL_CMD")
local Panel = ifelse(tc.active(hwnd) == "left", 8, 7)
local TMLB = childwin.handle(hwnd, "TMyListBox", Panel)
local Current = win.sendmessage(TMLB, 0x0188, 0, 0)
local i, Group, Counter

for(i = Len; i > 0; i--)
	Group = select(Name, i, i)
	if(not miscplugin.is_int(Group))
		break

endfor

if(i) do
	Group = select(Name, i)
	Counter = select(Name, i - Len)
else
	Group = ""
	Counter = Name
endif

for(i = 0; 1; i++)
	Len = fill(repeat("0", length(Counter)), Counter + i)
	Name = Group ++ Len
	if(not file.validpath(Path ++ "\" ++ Name ++ "." ++ Ext))
		break
		
endfor

win.sendmessage(TMLB, 0x0183, Current, Current + i - 1)

Comments:

Suppose there are some files with the same extension and consecutive numbering like this:

file-001.txt
file-002.txt
file-003.txt
file-004.txt
file-006.txt

Placing cursor on the first file and running the script results in selecting four files, because the file-005.txt file is absent.


All Scripts Total Commander TotalCmd.net PowerPro