-- Copy files with recovery FoldersTree from FullPath FileNames -- v1.2 local DisabledPlugins={ -- [win.Uuid("B77C964B-E31E-4D4C-8FE5-D6B0C6853E7C")]=true -- TmpPanel } local re=regex.new([[^(?:[A-Z]:|\\)\\(.*?)([^\\]+)$]]) local ra=regex.new([[^(?:[A-Z]:|\\)\\(.+)$]]) 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 local cds=PP if FPath and FPath~="" then cds=cds.."\\"..FPath if cds:sub(-1,-1)=="\\" then cds=cds:sub(1,-2) end res=win.CreateDir(cds,"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,cds.."\\"..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 = function() return APanel.Format=="Branch" or APanel.Format=="Temporary panel" or APanel.Format=="LF Search: temporary panel" or APanel.Format=="Search results" end; condition = function() return panel.GetPanelInfo(nil,1).ItemsNumber>1 and ra:match(panel.GetPanelItem(nil,1,2).FileName) and PPanel.FilePanel and not PPanel.Plugin and not DisabledPlugins[panel.GetPanelInfo(nil,1).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,panel.GetPanelInfo(nil,1).CurrentItem,true) else ItemsNumber=panel.GetPanelInfo(nil,1).SelectedItemsNumber end for Item=1,ItemsNumber do local GPI=panel.GetSelectedPanelItem(nil,1,Item) local res=cf(PP,GPI) 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 } |