Merge and split merged files

Discuss and share scripts and script files...
Post Reply
waqu
Posts: 17
Joined: 04 Jan 2015 05:58
Location: Russia/Saint-Petersburg
Contact:

Merge and split merged files

Post by waqu »

Code: Select all

"Merge files"
 $exists=exists("<curitem>");
 if ($exists==1){
  foreach ($token,<get SelectedItemsPathNames |>){
   $i++;
   $md5=hash("md5","$token",3);
   $file=getpathcomponent("$token","file");
   $filesize=filesize("$token");
   writefile("<curitempath>\<curbase>.txt","$md5|$i|$file|$filesize<crlf>","a");
   writefile("<curitempath>\<curbase>.pak",readfile("$token","b"),"a","b");
  }
 }
 if ($exists==2){
  foreach ($curitem,<get SelectedItemsPathNames |>){
   $foldername=getpathcomponent("$curitem","file");
   $i="";
   foreach ($token,listfolder("$curitem")){
    $i++;
    $md5=hash("md5","$token",3);
    $file=getpathcomponent("$token","file");
    $filesize=filesize("$token");
    writefile("<curitempath>\$foldername.txt","$md5|$i|$file|$filesize<crlf>","a");
    writefile("<curitempath>\$foldername.pak",readfile("$token","b"),"a","b");
   }
  }
 }
"Split merged files"
 foreach ($curitem,<get SelectedItemsPathNames |>){
  $path=getpathcomponent("$curitem","path");
  $base=getpathcomponent("$curitem","base");
  new("$path\$base","dir");
  $position="1";
  foreach ($token,readfile("$path\$base.txt"),"<crlf>"){
   if ($token){
    $filesize=gettoken("$token",4,"|");
    $filename=gettoken("$token",3,"|");
    writefile("$path\$base\$filename",readfile("$path\$base.pak","b","$filesize",,"$position"),,"b");
    $position=$position+$filesize;
   }
  }
 }
Files must be less than 100Mb

Post Reply