Code: Select all
The same (will be selected):
03 Forgotten Hopes.flac | 06 Forgotten Hopes.mp3
1-14 Transacoustic.mp3 | 05 Transacoustic.ape
06 One Last Goodbye.mp3 | 2-05 One Last Goodbye.mp3
Code: Select all
The same (will be selected):
03 Forgotten Hopes.flac | 06 Forgotten Hopes.mp3
1-14 Transacoustic.mp3 | 05 Transacoustic.ape
06 One Last Goodbye.mp3 | 2-05 One Last Goodbye.mp3
Code: Select all
Macro {
key="ShiftDivide";
area="Shell Search";
description="Select files with the same names without numeric prefix and extension";
condition=function()
return APanel.Visible and PPanel.Visible and not APanel.Empty and not PPanel.Empty
end;
action=function()
Panel.Select(0,0) Panel.Select(1,0) -- deselect first
local ia,ip -- cycle counters for active/passive panel
local AName,PName,ANameOnly,PNameOnly -- file name in active/passive panel, file name in a/p panel without prefix and ext.
local i,j -- cycle counters for filename scan (searching for first alpha char.)
local s,t -- character from filename, if it is alpha char., do action and break cycle
for ia=1,APanel.ItemCount do
AName=mf.fsplit(Panel.Item(0,ia,0),0x4) -- name without extension
for i=0,mf.len(AName) do
s=mf.substr(AName,i,1)
i=i+1
if far.LIsAlpha(s) then ANameOnly=mf.substr(AName,i-1)
for ip=1,PPanel.ItemCount do
PName=mf.fsplit(Panel.Item(1,ip,0),0x4)
for j=0,mf.len(PName) do
t=mf.substr(PName,j,1)
j=j+1
if far.LIsAlpha(t) then PNameOnly=mf.substr(PName,j-1) break else PNameOnly='' end
end
if ANameOnly:upper()==PNameOnly:upper() then Panel.Select(0,1,1,ia) Panel.Select(1,1,1,ip) end
end
break
end
end
end;
end;
}
Code: Select all
Macro {
key ="ShiftDivide";
area ="Shell Search";
description ="Select files with the same names without numeric prefix and extension";
condition=function()
return APanel.Visible and PPanel.Visible and not APanel.Empty and not PPanel.Empty
end;
action=function()
Panel.Select(0,0) Panel.Select(1,0) -- deselect first
local PTable={}
for ip=1,PPanel.ItemCount do
local PNameOnly=mf.fsplit(Panel.Item(1,ip,0),0x4):match("%a.*") -- name without extension
if PNameOnly then
PNameOnly=mf.replace(PNameOnly,"[ _-.,!']",'') -- fastest
-- PNameOnly=regex.gsub(PNameOnly,"[ _-.,!']",'') -- slower
-- PNameOnly:gsub("[ _-.,!']",'') -- slowest
PNameOnly=PNameOnly:upper()
PNameOnly=mf.replace(PNameOnly,'THE ','')
PTable[ip]=PNameOnly
end
end
for ia=1,APanel.ItemCount do
local ANameOnly=mf.fsplit(Panel.Item(0,ia,0),0x4):match("%a.*")
if ANameOnly then
ANameOnly=mf.replace(ANameOnly,"[ _-.,!']",'')
-- ANameOnly=regex.gsub(ANameOnly,"[ _-.,!']",'')
-- ANameOnly:gsub("[ _-.,!']",'')
ANameOnly=ANameOnly:upper()
ANameOnly=mf.replace(ANameOnly,'THE ','')
for ip,PNameOnly in pairs(PTable) do
if ANameOnly==PNameOnly then
panel.SetSelection(nil,0,ip,true)
panel.SetSelection(nil,1,ia,true)
end
end
end
end
panel.RedrawPanel(nil,0)
panel.RedrawPanel(nil,1)
end;
}
Does it really work for you?
It is unusual.
Indeed, doesn't work at all...Does it really work for you?
I doubt, because it is not intended to process regexps.
Compare 20000 files takes one minute or more (large dirs or branch plugin). In small directories it is ok.Please define your meaning for "slow".
Code: Select all
local function norm(name)
name = mf.fsplit(name,0x4):match("%a.*")
return name and name:upper() or nil
end
Macro {
key="ShiftDivide";
area="Shell Search";
description="Select files with the same names without numeric prefix and extension";
condition=function()
return APanel.Visible and PPanel.Visible and not APanel.Empty and not PPanel.Empty
end;
action=function()
Panel.Select(0,0); Panel.Select(1,0)
local PTable={}
for ip=1,PPanel.ItemCount do
PTable[ip]=norm(Panel.Item(1,ip,0))
end
local a,p = {},{}
for ia=1,APanel.ItemCount do
local ANameOnly=norm(Panel.Item(0,ia,0))
if ANameOnly then
for ip,PNameOnly in pairs(PTable) do
if ANameOnly==PNameOnly then
a[#a+1],p[#p+1] = ia, ip
end
end
end
end
panel.SetSelection(nil,0,p,true)
panel.SetSelection(nil,1,a,true)
panel.RedrawPanel(nil,0)
panel.RedrawPanel(nil,1)
end;
}