Wich detected Script CC
Posted: 17 Jan 2026 20:50
Hello,
today I tried to build a Custom Column (CC) script for XYplorer for the first time.
My goal was to display the script type directly in a column, similar to how it is shown in the editor. I started from a basic template generated by ChatGPT and then tried to work through it on my own.
I have a background in the trades, with both practical and theoretical experience, but this is new territory for me, and from that I know very well that first independent attempts in a new field often contain ridiculous mistakes.
With that in mind, I would be grateful if someone could take a look at my script and point out errors or better approaches.
e.g.: I am still very skeptical about the design compared to other scripts from the forum, and furthermore, I do not get a correct specification for any script:
today I tried to build a Custom Column (CC) script for XYplorer for the first time.
My goal was to display the script type directly in a column, similar to how it is shown in the editor. I started from a basic template generated by ChatGPT and then tried to work through it on my own.
I have a background in the trades, with both practical and theoretical experience, but this is new territory for me, and from that I know very well that first independent attempts in a new field often contain ridiculous mistakes.
With that in mind, I would be grateful if someone could take a look at my script and point out errors or better approaches.
e.g.: I am still very skeptical about the design compared to other scripts from the forum, and furthermore, I do not get a correct specification for any script:
Code: Select all
$r = 1201;
$head = readfile(<cc_item>, 1, 300, $r);
if (!$head) return "";
// lowercase & trim für Vergleich
$h = lower(trim($head));
$ext = lower(gettoken(<cc_item>, -1, "."));
// 1) Shebang
if (startswith($h, "#!")) {
if (contains($h, "python")) return "Python Script";
if (contains($h, "bash") || contains($h, "sh")) return "Shell Script";
}
// 2) Extension
if ($ext == "ahk") return "AutoHotkey Script";
if ($ext == "py") return "Python Script";
if ($ext == "ps1") return "PowerShell Script";
if ($ext == "bat") return "Batch Script";
if ($ext == "cmd") return "Batch Script";
if ($ext == "sh") return "Shell Script";
if ($ext == "xys") return "XY Script";
if ($ext == "js") return "JavaScript";
// 3) Inhalt
if (contains($h, "autohotkey")) return "AutoHotkey Script";
if (contains($h, "import ") && contains($h, "def ")) return "Python Script";
if (contains($h, "param(") || contains($h, "get-command")) return "PowerShell Script";
// Fallback für allgemeine Textdateien
if (isin($ext, "txt|cfg|csv")) return "Allgemeiner Text";
// Alles andere
return "Nicht erkannter Inhalt";