-- Copy files with recovery FoldersTree from FullPath FileNames -- v1.3 local DisabledPlugins={ -- [win.Uuid("B77C964B-E31E-4D4C-8FE5-D6B0C6853E7C")]=true -- TmpPanel } local re=regex.new([[^(?:[A-Z]:|\\)\\(.*?)([^\\]+)$]]) local ra=regex.new([[^(?:[A-Z]:|\\)\\(.+)$]]) local GPI local function cf(PP,GPI) local res,FPath,FName = false if GPI.FileAttributes:find("d") then FPath=ra:match(GPI.FileName) else FPath,FName = re:match(GPI.FileName) end if FPath and FPath~="" then PP=PP.."\\"..FPath if PP:sub(-1,-1)=="\\" then PP=PP:sub(1,-2) end res=win.CreateDir(PP,"t") if not res then far.Message(FPath,"Warning! Directory not created",nil,"w") end end if FName and res~=nil then res=win.CopyFile(GPI.FileName,PP.."\\"..FName) if not res then far.Message(FName,"Warning! File not copied",nil,"w") end end return res end Macro { description="Copy files with recovery FoldersTree from FullPath FileNames"; area="Shell"; key="ShiftF5"; -- condition for Branch, TmpPanel, LFSearch, RESearch and other FilePanels with FullPath FileNames condition = function() GPI=panel.GetPanelInfo(nil,1) return GPI.ItemsNumber>1 and ra:match(panel.GetPanelItem(nil,1,2).FileName) and PPanel.FilePanel and not PPanel.Plugin and not DisabledPlugins[GPI.OwnerGuid] end; action = function() --local ttime=far.FarClock() local t,PP,ItemsNumber = {},PPanel.Path0 if not APanel.Selected and APanel.Current~=".." then ItemsNumber=1 panel.SetSelection(nil,1,GPI.CurrentItem,true) else ItemsNumber=GPI.SelectedItemsNumber end for Item=1,ItemsNumber do local res=cf(PP,panel.GetSelectedPanelItem(nil,1,Item)) if not res then break end table.insert(t,Item) end panel.ClearSelection(nil,1,t) panel.RedrawPanel(nil,1) --far.Message(far.FarClock()-ttime,"mcs") end } |