MarkStep

Title MarkStep
File Name MarkStep.txt
Description Mark files with specific step
Author Vochomurka
Parameters -
Plugins Called win, childwin, tc, miscplugin
Icon
Version 3.0
Updated on 16.06.2014
local hwnd = win.handle("c=TTOTAL_CMD")
local Panel = ifelse(tc.active(hwnd) == "left", 0, 1)
local i, Unmark, To
local Step = 2
local What = "All"

local Result = win.childhandlelist(hwnd, "c=TMyListBox")
local From = vec.createfromwords(Result)

if(From <= 0) do
	messagebox("ok error", "Vector not created", "VEC plugin error #1")
	quit
endif

for(i = 0; i < From.length; i++)
	if(win.gettext(From[i]) == "W_FtpLogList") do
		From.delete(i)
		break
	endif
endfor

if(From.length != 2) do
	messagebox("ok error", "Wrong number of TMyListBox windows", "MarkStep script")
	quit
endif

local Counter = win.left(From[0])*win.top(From[0])
To = win.left(From[1])*win.top(From[1])
local TMLB = ifelse(Counter < To, From[Panel], From[(-1)*Panel + 1])

local Current = win.sendmessage(TMLB, 0x0188, 0, 0)
Counter = win.sendmessage(TMLB, 0x018B, 0, 0)

local Cap = "File " ++ Current ++ " of " ++ Counter
Result = Inputdialog("~Step=Step, What=Files to mark??All|Current & above|Current & below, Unmark=Unmark??", Cap)

if(not Result)
	quit

if(not miscplugin.is_int(Step) || Step <= 0) do
	messagebox("ok error", "Invalid step: " ++ Step, "'MarkStep' Script")
	quit
endif

if(What == "All") do
	From = 0
	To = Counter
elseif(What == "Current & above")
	From = 0
	To = Current
elseif(What == "Current & below")
	From = Current
	To = Counter
endif

Unmark = not(Unmark)

for(i = From; i < To; i = i + Step)
	win.sendmessage(TMLB, 0x0185, Unmark, i)
endfor

win.setfocus(hwnd)

Comments:

Attention! This script does not work in Total Commander 7.5 pb1 and pb2!

This script for Total Commander 7.0 and older.

This script can be useful at working with the results of searching duplicate files. After the search is finished, it is convenient to press the "Feed to listbox" button, for example:

Dotted lines separate pairs being duplicates ("same size" and "same contents" in the present case). As a rule, the next action is to select files according to a simple regularity, such as "every second", "all but every third", etc. It's easy if the number of files is not too great, otherwise it's a very exhausting job.

Suppose we need to mark every second file starting from the fourth pair. Put the cursor on the first file to select and run the script. In the dialog box that appears the input must be as follows:

Distance between files to mark is given by the "Step" edit box. Step is an integer greater than 1 (default 2). "Files to mark" dropdown list contains the following choices: "All" (default), "Current & above", "Current & below". The script also allows to unmark rather than to mark files - to switch this mode on, check "Unmark". So, the multiple execution of script allows to select files according to more complex regularity, despite the number of files to select.

In the present simple case after pressing "OK" result would be:

The script works also in a usual file panel, but I can hardly imagine the situation when it could be useful.


All Scripts Total Commander TotalCmd.net PowerPro