EditFileComments

Title EditFileComments
File Name EditFileComments.txt
Description Edit descriptions for group of files
Author Vochomurka
Parameters "%F"
Plugins Called file, win, childwin
Icon
Version 3.1
Updated on 15.08.2013
args Temp
local List = file.readall(Temp)
local Counter = line(List, 0)
local hwnd = win.handle("c=TTOTAL_CMD")

if(Counter == 1) do
	win.postmessage(hwnd, 0x400+51, 2700, 0)
	quit
endif

local Str, Class, Path, Name, Result, NewLine
local Where = "default - Instead"

Temp = "~Str=Comment string, Where=Location of new string relative to old one??"
Temp ++= "Before|After|Instead, NewLine=\ is a newline char??"

@CommentString
Result = Inputdialog(Temp, "Edit descriptions for " ++ Counter ++ " files")

if(not Result)
	quit

if(not Str) do
	Result = "Comment string is not specified. Would you like to delete old comments?"
	Result = messagebox("yesnocancel question", Result, "'EditFileComments' script")
	if(Result == 7) do
		jump CommentString
	elseif(Result == 0) do
		quit
	endif
endif

if(find(Str, "\") != -1 && NewLine)
	Str = replacechars(Str, "\", "\n") ++ esc(?+\x04+, ?+\+) ++ esc(?+\xC2+, ?+\+)

for each line Class in List
	Path = file.folder(Class) ++ "\"
	Name = file.nametype(Class)
	if(Result == 6) do
		Class = "d"
	else
		if(Where == "default - Instead" || Where == "Instead") do
			Class = "s"
		elseif(Where == "Before") do
			Class = "b"
		elseif(Where == "After") do
			Class = "a"
		endif

	endif

;Sub_Descript_ion - name of script Sub_Descript_ion;
	runfile.Subs\Sub_Descript_ion(Path, Name, Str, Class)
endfor

wait.for(50)
win.setfocus(hwnd)
win.sendmessage(hwnd, 0x400+51, 540, 0)

Comments:

This script for Total Commander 7.0 and older.

One day it was required to edit descriptions for several files rather than for one. I was amazed to learn that Total Commander doesn't give such opportunity. I think it's an annoying defect, but it can be eliminated by means of PowerPro.

The script is developed in such a way that if there is no group selected, then the command cm_EditComment is executed. Thus, it is a good idea to assign the Ctrl+Z hotkey to the script. If you will never have the necessity to edit many descriptions, you will not learn the difference between running the script and the command. But, if you ever have such need, I will be glad to help you with my script.

So, when some files are selected, the following dialog window appears:

The window caption shows the quantity of files selected (3 on the screenshot). In the "Comment string" edit box enter any string or leave it empty. In the latter case the comments, if any, for files selected will be deleted after confirmation.

In the "Location..." dropdown list you can choose where to put the new comment relative to the old one (if any) - before, after or instead (default).

The "\ is a newline char" flag allows to set multiline comments (new feature in version 7.5). If this flag is set, then the backslash character in the comment body is treated as a newline character. Special characters of the multiline comment termination are added automatically after the line you enter in the dialog box. Hence, the newline flag in combination with the "Before" option deletes old comment! Be careful!


Main Page Total Commander PowerPro