Advertisement
zefie

Quickie script to reassemble split file with progress

Apr 2nd, 2012
405
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.32 KB | None | 0 0
  1. <?php
  2. $files = array('kenzi.vhd.aa', 'kenzi.vhd.ab', 'kenzi.vhd.ac', 'kenzi.vhd.ad', 'kenzi.vhd.ae', 'kenzi.vhd.af', 'kenzi.vhd.ag', 'kenzi.vhd.ah', 'kenzi.vhd.ai', 'kenzi.vhd.aj', 'kenzi.vhd.ak', 'kenzi.vhd.al', 'kenzi.vhd.am', 'kenzi.vhd.an', 'kenzi.vhd.ao', 'kenzi.vhd.ap', 'kenzi.vhd.aq', 'kenzi.vhd.ar', 'kenzi.vhd.as', 'kenzi.vhd.at', 'kenzi.vhd.au', 'kenzi.vhd.av', 'kenzi.vhd.aw', 'kenzi.vhd.ax', 'kenzi.vhd.ay', 'kenzi.vhd.az', 'kenzi.vhd.ba', 'kenzi.vhd.bb', 'kenzi.vhd.bc', 'kenzi.vhd.bd', 'kenzi.vhd.be', 'kenzi.vhd.bf', 'kenzi.vhd.bg', 'kenzi.vhd.bh', 'kenzi.vhd.bi', 'kenzi.vhd.bj', 'kenzi.vhd.bk', 'kenzi.vhd.bl', 'kenzi.vhd.bm', 'kenzi.vhd.bn', 'kenzi.vhd.bo', 'kenzi.vhd.bp', 'kenzi.vhd.bq');
  3.  
  4. $out = "/home/zefie/Desktop/tmp/kenzi.vhd";
  5.  
  6. $written = 0;
  7. $outp = fopen($out,"w");
  8.  
  9.  
  10. foreach ($files as $file) {
  11.     $fp = fopen($file,'r');
  12.     while (!feof($fp)) {
  13.         $data = fread($fp,4096);
  14.         fwrite($outp,$data);
  15.         $written = ($written+strlen($data));
  16.         echo("File: ".$file." ~ Total Written: ".file_size($written)."                            \r");
  17.     }
  18.     fclose($fp);
  19. }
  20. fclose($outp);
  21.  
  22.  
  23. function file_size($size)
  24. {
  25.     $filesizename = array(" Bytes", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB");
  26.     return $size ? round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . $filesizename[$i] : '0 Bytes';
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement