how to check a list for missing pairs?

Features wanted...
Post Reply
Wanda
Posts: 55
Joined: 08 Jan 2011 01:08

how to check a list for missing pairs?

Post 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

admin
Site Admin
Posts: 64915
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: how to check a list for missing pairs?

Post 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.

Wanda
Posts: 55
Joined: 08 Jan 2011 01:08

Re: how to check a list for missing pairs?

Post 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?

highend
Posts: 14571
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: how to check a list for missing pairs?

Post 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 ;)
One of my scripts helped you out? Please donate via Paypal

Wanda
Posts: 55
Joined: 08 Jan 2011 01:08

Re: how to check a list for missing pairs?

Post 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

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: how to check a list for missing pairs?

Post 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

Wanda
Posts: 55
Joined: 08 Jan 2011 01:08

Re: how to check a list for missing pairs?

Post 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!

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: how to check a list for missing pairs?

Post 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!";

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: how to check a list for missing pairs?

Post 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";



eil
Posts: 1816
Joined: 13 Jan 2011 19:44

Re: how to check a list for missing pairs?

Post 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
Win 7 SP1 x64 100% 1366x768|1900x1080

Wanda
Posts: 55
Joined: 08 Jan 2011 01:08

Re: how to check a list for missing pairs?

Post by Wanda »

wonderful! thank u so much! now it's simpler, either

highend
Posts: 14571
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: how to check a list for missing pairs?

Post 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 :)
One of my scripts helped you out? Please donate via Paypal

Wanda
Posts: 55
Joined: 08 Jan 2011 01:08

Re: how to check a list for missing pairs?

Post 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]

Post Reply