SisterDel

Title SisterDel
File Name SisterDel.txt
Description Delete files from sister directories
Author Vochomurka
Parameters ("%P", "%O", "%E", "0|1|2", "n|e|b")
(see Comments)
Plugins Called file, vec, miscplugin
Icon
Version 1.0
Updated on 08.11.2005
local Path = arg(1)
local Name = arg(2)
local Ext = arg(3)
local Temp = Path ++ Name ++ "." ++ Ext
;Sub_ParsePath - name of script ParsePath;
local Parent = runfile.Subs\Sub_ParsePath(Temp, -1)
;SubDirList - name of script SubDirList;
local Size = runfile.SubDirList(Parent)
local i, Victim
local List = "Are you sure to delete the following files:\n"
local mpDlgText
local mpDlgCaption = "Sister Delete"
local mpIcon = "QUESTION"

if(arg(5) == "n") do
	Victim = Name ++ ".*"
elseif(arg(5) == "e") do
	Victim = "*." ++ Ext
elseif(arg(5) == "b") do
	Victim = Name ++ "." ++ Ext
endif

for(i = 0; i < Size; i = i + 1)
	v[i] = v[i] ++ "\" ++ Victim
	if(file.validpath(v[i]) == "0") do
		v[i] = ""
	else
		if(arg(4) == "1")
			List = List ++ "\n" ++ v[i]
	endif
endfor

if(arg(4) == "1") do
	mpDlgText = List
	if(miscplugin.messagebox(1, "&Yes", "&No") == "&No")
		quit
endif

Path = 0

for(i = 0; i < Size; i = i + 1)
	if(v[i] != "") do
		if(arg(4) == "2") do
			mpDlgText = "Delete " ++ v[i] ++ "?"
			if(miscplugin.messagebox(1, "&Yes", "&No") == "&No")
				jump NextFile
		endif
		file.delete(v[i])
		Path = Path + 1
	endif
@NextFile
endfor

local mpIcon = "INFORMATION"
mpDlgText = Path ++ " files are deleted"
miscplugin.messagebox(1, "OK")

vec.destroy(v)
vec.unload
miscplugin.unload

Comments:

Sister directory is that having the same parent with the current one. For example, for c:\Windows the sister directory is, in particular, the c:\Program Files directory.

Some applications create many sister directories each containing files with the same name (logs, reports, notes) that you don't need any longer. How to delete all of them by the Total Commander means?

  1. Press Alt+F7;
  2. Type a mask (perhaps the long one). Or first copy the name to the clipboard, then paste it into the "Search for" edit box, and finally correct the name to be mask;
  3. Press "Start search";
  4. When the search ends, press "Feed to listbox";
  5. Simplest way to select all is to press "*";
  6. Finally, press Del.

Then the resulting empty tab should be either re-read or closed. The conclusion is - it's too long procedure for such simple routine.

Three first parameters of the script are self-explanatory: path, name, extension of the current file to delete. Fourth parameter defines the delete confirmation:

Fifth parameter deals with the mask of files to delete relative to the current file. For example, if the current file is error.log:

Frankly, I use "b" only. All others are provided just for the versatility. For example, the "å" parameter could be used for files with gid, tmp, or ~tx extensions.


Main Page Total Commander PowerPro