Page 1 of 1

how to check a list for missing pairs?

Posted: 26 Jan 2012 17:46
by Wanda
I'd like a way to easily checking a long list of files against missing pairs.
Some times those files must have 1, 2 or 3 companion files. Mostly 1 at least.
thank you and have a nice yr all, 1st 2012 post from me! ^^

Code: Select all

file A.txt
file A.bkp
file B.bkp - missing .txt
file C.txt
file C.bkp
file D.txt - missing .bkp

Code: Select all

file A.txt
file A.bkp
file A.csv
file B.txt
file B.bkp - missing .csv
file C.txt
file C.bkp
file C.csv

Re: how to check a list for missing pairs?

Posted: 27 Jan 2012 10:06
by admin
I would use color filters against the extensions. Then it immediately jumps into the eye where the color rhythm is broken when you sort by name.

Re: how to check a list for missing pairs?

Posted: 28 Jan 2012 03:08
by Wanda
tried the color trick but it's still hard to select all those files manually over and over again.
any other suggestion? please?

Re: how to check a list for missing pairs?

Posted: 28 Jan 2012 04:18
by highend
I'd use scripting. Let the script gather all file names, format that list and make a report for which base file name misses it's pair(s). Shouldn't be too hard ;)

Re: how to check a list for missing pairs?

Posted: 28 Jan 2012 15:01
by Wanda
hello highend! can you please do so? I do not script, my brother sometimes do simple scripts but this one he's not able to. tks in advance

Re: how to check a list for missing pairs?

Posted: 28 Jan 2012 19:48
by Stefan
Wanda wrote:I'd like a way to easily checking a long list of files against missing pairs.
Some times those files must have 1, 2 or 3 companion files. Mostly 1 at least.

Code: Select all

file A.txt
file A.bkp
file B.bkp - missing .txt
file C.txt
file C.bkp
file D.txt - missing .bkp

You may want to try this script:

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.		 		 			  */


  $exts = input('XYplorer - Lookup missed files',coma separated list of extensions to checking for);
  end($exts == "");
  $exts = replace($exts, " ", "");  //trim, remove spaces
  $exts = replace($exts, ";", ","); //allow other separators too
  $exts = replace($exts, "|", ","); //allow other separators too 

  $missed = "";

  $selFiles = get("SelectedItemsNames", "|");
  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{ 
                         /* be sure to add file only once to output */
                         if (strpos($missed, "$base.$ext") == -1){
                              /* add file to output */
                              $missed = $missed . "$base.$ext" . "<crlf>";
                         }
                 }
         }
  }


   /* Result:  	  	  		   	 				*/
   if ($missed == "") {$missed = "none";}
   beep 800,100; beep 400,100; beep 600,100;
   text "Missed in<crlf><curpath>\<crlf 2>$missed";

HTH? :D

Re: how to check a list for missing pairs?

Posted: 28 Jan 2012 20:26
by Wanda
thank you very much stefan! :D
is there a way the script do not report double entries in lists like
file A.bkp
file A.csv
file A.txt
file B.bkp
file B.txt
file C.bkp
file C.csv
file C.txt

=file B.csv is being reported twice!

Re: how to check a list for missing pairs?

Posted: 28 Jan 2012 22:35
by Stefan
I had anyway updated my script (it seems, you was faster to copy then i to edit) to prevent exactly that. Just copy the script again and see if it works now better.


- - -



In addition
One may want to add this at top of the script too:

Code: Select all

  end(get("CountSelected") == 0),"Missing files script - No files selected, script ends here!";

Re: how to check a list for missing pairs?

Posted: 28 Jan 2012 23:09
by Stefan
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";



Re: how to check a list for missing pairs?

Posted: 28 Jan 2012 23:42
by eil
i was watching this topic as this could be useful sometimes for my own. Stefan, your modified script is wonderful! :D just forgot to edit comments/description. :P

Re: how to check a list for missing pairs?

Posted: 29 Jan 2012 00:02
by Wanda
wonderful! thank u so much! now it's simpler, either

Re: how to check a list for missing pairs?

Posted: 29 Jan 2012 02:38
by highend
Sorry, I was actually writing one (this morning) but I totally forgot about my girlfriend... :P

I took a different approach (getting the first entry of a list of files (via folderreport) and compare it to $count = $countedextensions -1 following entries.

Stefan's version uses a better and more simple way by using the file extensions to check if anything is missing :)

Re: how to check a list for missing pairs?

Posted: 29 Jan 2012 14:43
by Wanda
no prob highend just do not forget your girlfriend again :wink:

another pretty common situation I come across is when backing up my dvds i have to split the double layer ones into regular 4 gb so i have to check for:

Code: Select all

VTS_01_0.BUP
VTS_01_0.IFO
VTS_01_0.VOB
VTS_01_1.VOB
VTS_78_0.BUP
VTS_78_0.IFO
            - missing, should be VTS_78_0.VOB
VTS_78_1.VOB

Code: Select all

VTS_01_0.BUP
VTS_01_0.IFO
VTS_01_0.VOB
            - missing, should be VTS_01_1.VOB
VTS_78_0.BUP
VTS_78_0.IFO
VTS_78_0.VOB
VTS_78_1.VOB
any update available for that please?[/color]