File validation.

Discuss and share scripts and script files...
Post Reply
tiago
Posts: 589
Joined: 14 Feb 2011 21:41

File validation.

Post by tiago »

I made a massive backup onto external drives and get caught by few surprises using Acronis and XYplorer "backup to" feature. Those were all related to invalid names on source paths and I thought that some sort of "file validation tool" could be built using scripting, which should verify all file paths on a drive then pop a notice on non-standard files. "Which standards?": ANSI encoding on path names (allowed) or simple diacritics on file paths (must be reported, though). Everything else like double byte chars on path names must be reported in another section either.

With such verification tool I won't be stuck for hours on my backup operations as beforehand I can check and fix such problems avoiding any dialog windows I may forget to check ("backup operations/ASK on failures") not to mention other apps that won't allow such level of customization.
Power-hungry user!!!

tiago
Posts: 589
Joined: 14 Feb 2011 21:41

Re: File validation.

Post by tiago »

this will do and certainly will require a bit of customization.
i made an alternative version which scans directory after directory producing smaller folder reports for my convenience. It's an idea for you.
so many PIT@ would be saved by using this prior to those backups, o lord... :roll:

Code: Select all

//this will also generate a recursive report on contained files

      end(compare("<xyver>", '9.90.0606', 'v') < 0, "XYplorer v9.90.0606+ only.");

      $reportModifiedDate1 = <date hh:nn:ss yyyy/mm/dd>; // this is the real thing, replaced for debug reasons

   $st = <curpath>;
   $rp = folderreport("items:{dir {fullname}|{fullname}|}", "r", , "r");
   writefile("$st\Scanned Files.txt", $rp, r, t);

   $Flist = "";
   foreach($line, $rp, "<crlf>")
   
   {
   $ref = strlen("$line");
   $ix = "0"; //    $ix = "0";
   while ($ix <= $ref) {
   $s1 = substr($line, $ix, 1);
  $string = asc($s1);
  if( $string > 96 && $string < 123) { $ix++; continue; }
  elseif( $string == "") { $ix++; continue; }
  elseif( $string == "32") { $ix++; continue; }
//  elseif( $string == "<crlf>") { $ix++; continue; }
  elseif ( $string > 47 && $string < 58) { $ix++; continue; }
  elseif( $string > 64 && $string < 91) { $ix++; continue; }
//insert here your white list of allowed chars
//remember: they MUST be stated in ASC values!
//currently allowed: " " (32), (,),:,.,\,_,-,
  elseif( $string == "95") { $ix++; continue; }
  elseif( $string == "92") { $ix++; continue; }
  elseif( $string == "40") { $ix++; continue; }
  elseif( $string == "41") { $ix++; continue; }
  elseif( $string == "45") { $ix++; continue; }
  elseif( $string == "46") { $ix++; continue; }
  elseif( $string == "58") { $ix++; continue; }
//step here to easily know which one will raise a flag
 //step;
  elseif( $string != "58") { $ix++; $Flist = "$Flist" . "$line<crlf>"; continue; }
                        }
   }
   goto $st;

      $reportModifiedDate2 = <date hh:nn:ss yyyy/mm/dd>; // this is the real thing, replaced for debug reasons

  $differenceOfDates = datediff($reportModifiedDate1, $reportModifiedDate2, s);

  $DAYS_PER_YEAR = 365.25;
  $HOURS_PER_DAY = 24;
  $MINS_PER_HOUR = 60;
  $SECS_PER_MIN = 60;
  $sep = " ";
  $duration = "";
 
  $Secs = $differenceOfDates;
 
  $Mins = $Secs \ $SECS_PER_MIN;
  $Hours = $Mins \ $MINS_PER_HOUR;
  $Days = $Hours \ $HOURS_PER_DAY;
  $Years = $Days \ $DAYS_PER_YEAR;
  If ($Years > 0) {
    $duration = $duration . $sep . $Years . "y";
  }
  $Days = $Days % $DAYS_PER_YEAR;
  If ($Days > 0) {
    $duration = $duration . $sep . $Days . "d";
  }
  $Hours = $Hours % $HOURS_PER_DAY;
  If ($Hours > 0) {
    $duration = $duration . $sep . $Hours . "h";
  }
  $Mins = $Mins % $MINS_PER_HOUR;
  If ($Mins > 0) {
    $duration = $duration . $sep . $Mins . "min";
  }
  $Secs = $Secs % $SECS_PER_MIN;
  If ($Secs > 0) {
    $duration = $duration . $sep . $Secs . "sec";
  }

  $duration = substr($duration, strlen($sep));

  If ($Flist == "") { text "$reportModifiedDate1 - starting date;<crlf>$reportModifiedDate2 - ending date;<crlf><crlf>$duration - duration of execution.<crlf 2>NO SUSPECT FILES FOUND!"; status "done. $duration - duration."; end 1; }
  Elseif ($Flist != "") { text "$reportModifiedDate1 - starting date;<crlf>$reportModifiedDate2 - ending date;<crlf><crlf>$duration - duration of execution.<crlf 2>This is the RECURSIVE list of supect files:<crlf>$Flist"; status "done. $duration - duration."; }
Power-hungry user!!!

Post Reply