use p7zip as file properties detector ?

2012-11-04
2013-05-28
  • does anyone use p7zip with PHP scripting to determine file properties?  Like the getID3 project : http://www.getid3.org .  It seems that p7zip knows a lot of mime-types!  I found http://forums.modem-help.co.uk/viewtopic.php?t=707 , giving info & some pseudo-PHP code, showing typical usage.

     
  • RichRumble
    RichRumble
    2012-11-04

    I use windows COM/WMI for files on windows machines, I don't have anything for linux. It often knows the file type even without the proper extension, plus all the meta-data you see when looking at (advanced)properties. This might not be the same goal you have in mind.
    <?PHP
    header("Content-Type: text/plain"); //http://technet.microsoft.com/en-us/library/ee176615.aspx
    $arrHeaders = array(284);  //XP Only has 40 or so possible meta-data types
    $objShell = new COM("Shell.Application");
    $objFolder = $objShell->Namespace('c:\temp');  //Change to suit the proper path
    for ($i=0; $i<=283; $i=$i+1) {
      $arrHeaders=$objFolder->GetDetailsOf($objFolder->Items, $i);
    }
    foreach ($objFolder->Items as $strFileName) {
      for ($i=0; $i<=283; $i=$i+1) {
    Echo $i . "\t" . $arrHeaders . ": " . $objFolder->GetDetailsOf($strFileName, $i) . "\r\n";
      }
    }
    ?>