CleanComments

Название CleanComments
Имя файла (*.txt) CleanComments.txt
Описание Удаляет из файла descript.ion все, кроме пар "имя описание" для существующих файлов
Автор Вахмурка
Параметры "%P"
Вызываемые плагины file, vec
Иконка
Версия 1.0
Дата обновления 28.04.2008
args Path
local Source = Path ++ "descript.ion"

if(not file.validpath(Source)) do
	messagebox("ok error", "File " ++ Source ++ " is missing", "No comment file")
	quit
endif

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

w = vec.create(1, 1)
if(w <= 0) do
	messagebox("ok error", "Vector not created", "VEC plugin error #2")
	quit
endif

local fh = file.open(Source, "r")
local i, Str, FileName, Comment, Comms
local Quote = esc(?+\"+, ?+\+)

if(fh > 0) do
	for(not(file.eof(fh))) 
		Str = file.readstring(fh)
		if(not Str)
			continue

		FileName = word(Str, 1)

		if(file.validpath(Path ++ FileName)) do
			vec.insert(v, Comms, FileName)
			Comment = select(Str, length(FileName) - length(Str) + 1)
			vec.insert(w, Comms, Comment)
			Comms++
		else
			FileName = word(Str, 1, Quote)
			if(file.validpath(Path ++ FileName)) do
				vec.insert(v, Comms, Quote ++ FileName ++ Quote)
				Comment = select(Str, length(FileName) - length(Str) + 3)
				vec.insert(w, Comms, Comment)
				Comms++
			endif
		endif
	endfor
else
	messagebox("ok error", "File not opened", "FILE plugin error #1")
	quit
endif

file.close(fh)

if(not Comms) do
	Str = "File " ++ Source ++ " seems to contain no file comments!"
	messagebox("ok warning", Str, "CleanComment Script")
	vec.destroy(v)
	vec.destroy(w)
	quit
endif

file.delete(Source)
fh = file.open(Source, "w")

for(i = 0; i < vec.length(v); i++)
	file.writeline(fh, v[i] ++ " " ++ w[i])
endfor

file.close(fh)
vec.destroy(v)
vec.destroy(w)

На главную Все о Total Commander PowerPro PowerPro & Total Commander