More improved (well, depends) script.
No more asking for extensions but auto-collect the ext itself.
Code: Select all
/* Check if each file exists with each given extension. */
/* 1. Select your files to check. */
/* 2. Answer the prompt which extensions have to be there (case non-sensitive) */
/* 3. The script will check each and every base name with each entered extension if file exists. */
/* 4. You will be prompted with an result text box with the missing files. */
end(get("CountSelected") == 0),"Missing files script - No files selected, script ends here!";
/* Get list of all selected extensions */
set $ExtArray;
$selFiles = get("SelectedItemsNames", "|");
foreach($file, $selFiles){
$extension = gettoken($file, -1, ".");
if (strpos($ExtArray, $extension) == -1){
$ExtArray = $ExtArray . $extension . ",";
}
}
$ExtArray = substr($ExtArray, 0, strlen($ExtArray)-1); //trim last coma
$exts = $ExtArray;
/* Ask the user for correctness (here disabled) */
// $exts = input('XYplorer - Lookup missed files',coma separated list of extensions to checking for, $ExtArray);
// end($exts == "");
// $exts = replace($exts, " ", ""); //trim, remove spaces
// $exts = replace($exts, ";", ","); //allow other separators too
// $exts = replace($exts, "|", ","); //allow other separators too
/* Find missed files */
$missed = "";
foreach($file, $selFiles){
//* this strpos() needs XYplorer v10.60.0120 - 2011-12-06 or above */
$base = substr($file, 0, strpos($file, ".", -1) ); //msg $base,1;
//$extension = gettoken($file, -1, "."); //msg $extension,1;
foreach($ext, $exts, ","){
//step; status "<curpath>\$base.$ext" ; //debuging
/* exists(item) == 1 => exists (file) */
if ( exists("<curpath>\$base.$ext") == 1){
//OK! Do nothing.
}else{
//add file only once to output:
if (strpos($missed, "$base.$ext") == -1){
$missed = $missed . "$base.$ext" . "<crlf>";
}
}
}
}
/* Result: */
if ($missed == "") {$missed = "none";}
beep 800,100; beep 400,100; beep 600,100;
text "Missed $exts in<crlf><curpath>\<crlf 2>$missed";