The F7 Preview Panel of a ZIP archive shows a nice picture:
...but not any useful information: For example, I need to see the ZIP COMMENT stored in the ZIP archive (if any)!
The F7 Preview Panel of a ZIP archive shows a nice picture:
...but not any useful information: For example, I need to see the ZIP COMMENT stored in the ZIP archive (if any)!
The metadata panel may show that information. (The viewer probably isn't the most suitable place for it.)
Unfortunately, the MetaData Panel does not show the ZIP Comment:
It is very easy to get the ZIP Comment in Delphi code:
function GetZipComment(const ZipFileName: string): string;
var
ZipFile: TZipFile;
begin
Result := '';
if not System.SysUtils.FileExists(ZipFileName) then
EXIT;
ZipFile := TZipFile.Create;
TRY
ZipFile.Open(ZipFileName, zmRead);
Result := ZipFile.Comment;
FINALLY
ZipFile.Free;
END;
end;
Try adding this script column (requires 7zip installed and accessible from path):
ZipComment.opusscriptinstall (1.9 KB)
Code:
// ZipComment
// (c) 2025 Stephane
// This is a script for Directory Opus.
// See https://www.gpsoft.com.au/endpoints/redirect.php?page=scripts for development information.
// Called by Directory Opus to initialize the script
function OnInit(initData)
{
initData.name = "ZipComment";
initData.version = "1.0";
initData.copyright = "(c) 2025 Stephane";
// initData.url = "https://resource.dopus.com/c/buttons-scripts/16";
initData.desc = "";
initData.default_enable = true;
initData.min_version = "13.0";
}
// Called to add columns to Opus
function OnAddColumns(addColData)
{
var col = addColData.AddColumn();
col.name = "ZipComment";
col.method = "OnZipComment";
col.label = "ZipComment";
col.justify = "left";
col.autogroup = true;
}
// Implement the ZipComment column
function OnZipComment(scriptColData)
{
if (!scriptColData.item.InGroup("name:Archives")) return;
var cmd = ExtSystem.RunHiddenEx("7z.exe", 'l "' + scriptColData.item.realpath + '"');
DOpus.Output("res = " + cmd.stdout);
var match = cmd.stdout.match(/^Comment = (.*)$/m);
if (!match)
return;
if (match.length >= 2)
scriptColData.value = match[1];
}
if (typeof ExtSystem === "undefined") {
var ExtSystem = (function () {
var my = {};
///////////////////////////////////////////////////////////////////////////////
my.RunHiddenEx = function RunHiddenEx(exe, params, tmpFileBase, tmpFileExt, shell, fso) { //v1.2
if (!fso) fso = new ActiveXObject("Scripting.FilesystemObject");
if (!shell) shell = new ActiveXObject("WScript.Shell");
if (!tmpFileBase) tmpFileBase = "DO.Temp.";
if (!tmpFileExt) tmpFileExt = ".txt";
var tmpFileStdout = this.GetTmpFileName(tmpFileBase, tmpFileExt, fso).fullname;
var tmpFileStderr = tmpFileStdout+".err"+tmpFileExt;
var cmd = '%comspec% /c ""'+exe+'" '+params+' >"'+tmpFileStdout+'" 2>"'+tmpFileStderr+'""';
// dout ("CMD='" + cmd + "'");
var result = {};
result.cmd = cmd;
if (exe.match(/^([A-z]:\\.+|\\\\(.*?)\\.+)$/)) { //test path to exe if given
if (!fso.FileExists(exe)){
var msg = "E Executable not found ["+exe+"]";
DOpus.Output(msg);
throw msg;
}
// else dout (">> '" + exe + "' exists");
}
result.returncode = shell.Run( cmd, 0, true);
//result.returncode = shell.Run( cmd, 1, true);
result.stdout = this.ReadFile(tmpFileStdout, fso); fso.DeleteFile(tmpFileStdout);
result.stderr = this.ReadFile(tmpFileStderr, fso); fso.DeleteFile(tmpFileStderr);
return result;
}
///////////////////////////////////////////////////////////////////////////////
my.ReadFile = function ReadFile(path, fso){
fso = fso || new ActiveXObject("Scripting.FilesystemObject");
var content = "";
if (!fso.FileExists(path)){
return content;
}
var file = fso.OpenTextFile( path, 1, -2); // Read, UseDefaultEncoding
if (!file.AtEndOfStream)
content = file.ReadAll();
file.Close();
return content;
}
///////////////////////////////////////////////////////////////////////////////
my.ReadFileByLines = function ReadFileByLines(path, fso){
var vOut = DOpus.Create.Vector();
fso = fso || new ActiveXObject("Scripting.FilesystemObject");
var content = "";
if (!fso.FileExists(path)){
return vOut;
}
var file = fso.OpenTextFile(path, 1, false, -2); // Read, do not create, Unicode
while (!file.AtEndOfStream) {
// DOpus.Output("ext system : reading 1 line");
vOut.push_back(file.ReadLine());
}
file.Close();
return vOut;
}
///////////////////////////////////////////////////////////////////////////
my.GetTmpFileName = function GetTmpFileName(prefix, extension, fso) {
fso = fso || new ActiveXObject("Scripting.FilesystemObject");
var tFolder = fso.GetSpecialFolder(2); //2 = temp folder
var tFile = fso.GetTempName();
if (prefix!=undefined) tFile=prefix+tFile;
if (extension!=undefined) tFile+=extension;
return {
path : tFolder.Path,
name : tFile,
fullname: tFolder.Path+'\\'+tFile
};
}
return my;
}());
}
///////////////////////////////////////////////////////////////////////////
// Helper dout function
function dout(msg, error, time) {
if (error == undefined) error = false;
if (time == undefined) time = true;
DOpus.output(msg, error, time);
}
Nice, thanks for the script!
But shouldn't Opus avoid too many external dependencies?
It should as much as possible, but it can't replace every bit of software neither.
So, when you need something that is not provided, you can revert to external tools.
That pretty much makes me think about some script you can find that will revert to mediainfo to get extra information about video/audio files.
This reminds me of an ad for car accessories: "If you need something that is not included, such as a steering wheel, then use our range of accessories or make your own steering wheel."