Top

/splitfile


mIRC Code
+ 0 likes
Please Register to submit score.
Bookmark and Share
Average Score  7.8 (of 4 scores)
Date Added  Aug 19, 2006
Last Updated  Aug 19, 2006
Tags  binary  file  split  splitfile 

Introduction

<pre>;
; /splitfile [-bdfor] [OutputDir] &#60N&#62 &#60file&#62
;
; /splitfile splits a file into multiple parts of N bytes.
; Usefull for example if you want to send large files over e-mail, but there is a
; size limit. The script automatically generates a .bat file which puts the files
; back together.
;
; CAUTION!: N size is in bytes! If you specify a very small amount the script will
; generate a lot (ten-thousands) of files which may crash / seriously slow-
; down your computer. The script leaves it in the users hands to decide how
; many files there will be created and doesn't check for this.
;
;
; If you specify the -b switch, no batch file will be created
;
; If you specify the -d switch, you can change the output directory to something
; else in stead of the same directory the original file is in (Use quotes if the output
; dir contains spaces)
;
; If you specify the -f switch, the first N parameter will be the amount
; of files the original file will be split in, in stead of the amount of bytes
; for each file.
;
; If you specify the -o switch, all files that already exists will be overwritten,
; else an error message will occur.
;
; If you specify the -r switch, the original file will be removed
;</pre>

Grab the Code

;
; /splitfile [-bdfor] [OutputDir] <N> <file>
;
; /splitfile splits a file into multiple parts of N bytes.
; Usefull for example if you want to send large files over e-mail, but there is a
; size limit. The script automatically generates a .bat file which puts the files
; back together.
;
; CAUTION!: N size is in bytes! If you specify a very small amount the script will
;           generate a lot (ten-thousands) of files which may crash / seriously slow-
;           down your computer. The script leaves it in the users hands to decide how
;           many files there will be created and doesn't check for this.
;
;
; If you specify the -b switch, no batch file will be created
;
; If you specify the -d switch, you can change the output directory to something
; else in stead of the same directory the original file is in (Use quotes if the output
; dir contains spaces)
;
; If you specify the -f switch, the first N parameter will be the amount
; of files the original file will be split in, in stead of the amount of bytes
; for each file.
;
; If you specify the -o switch, all files that already exists will be overwritten,
; else an error message will occur.
;
; If you specify the -r switch, the original file will be removed
;
 
alias splitfile {
  ; Version check
  ; ---
  if ($version < 6.17) splitfile_error Your version is too low, please upgrade to 6.17+
 
  ; Check optional switch
  ; ---
  var %switch
  if (-* iswm $1) {
    %switch = $1
    tokenize 32 $2-
  }
 
  ; Check Output directory
  ; ---
  var %outputdir = $nofile($2-)
  if (d isincs %switch) {
    %outputdir = $iif(*\ iswm $iif($noqt($1) == $1,$1,$gettok($1-,1,34)),$v2,$+($v2,\))
    tokenize 32 $gettok($2-,$+($numtok(%outputdir,32),-),32)
  }
 
  ; Set variables
  ; ---
  var &data, %file = $qt($2-), %size = $iif(f isincs %switch,$ceil($calc($file(%file) / $1)),$1), $&
    %parts = $int($calc($file(%file) / %size)), %batfile = $qt($+(%outputdir,$nopath($+($2-,.bat)))), $&
    %partfile, %bfile, %n = 0
 
  ; Extra error checking
  ; ---
  if ($1 <= 0) splitfile_error $1 $+ : Invalid parameter
  if (!%parts) splitfile_error No need to split the file!
  if ($exists(%batfile)) {
    if (o isincs %switch) .remove %batfile
    else splitfile_error %batfile already exists.
  }
 
  ; Binary read & write loop
  ; ---
  while (%n <= %parts) {
 
    %partfile = $nopath($+($2-,.,p,$base(%n,10,10,3)))
    %bfile = $qt($+(%outputdir,%partfile))
 
    ; Read
    bread %file $calc(%n * %size) %size &data
 
    ; Check
    if ($exists(%bfile)) {
      if (o isincs %switch) .remove %bfile
      else splitfile_error %bfile already exists.
    }
 
    ; And write
    bwrite $qt($+(%outputdir,%partfile)) -1 -1 &data
 
    ; Batch file creation
    ; ---
    if ((b !isincs %switch) && (%n)) {
      write %batfile @ copy /b $qt($nopath($iif(%n = 1,$+($2-,.p000),%file))) + $qt(%partfile) $&
        $qt($nopath(%file)) >nul
    }
    inc %n
  }
 
  ; Optional remove original file
  ; ---
  if (r isincs %switch) .remove %file
  return
 
  ; Error Catching routine
  ; ---
  :error | tokenize 32 $error
  splitfile_error $3-
 
}
 
alias -l splitfile_error {
  ; Error output
  ; ---
  echo $color(info) -eg * /splitfile: $$1-
  halt
}

Comments

  (2)  RSS
Pariah
Comments: 45
 
mIRC Snippet:  /splitfile
Posted on Aug 20, 2006 6:01 am
Very nice job, QuickStep. I'd never even thought of doing anything like this with mIRC.
Staccia
Comments: 19
 
mIRC Snippet:  /splitfile
Posted on Feb 1, 2007 10:25 pm
what exactly does this do....

Commenting Options

Register or Login to Hawkee.com or use your Facebook or Twitter account by clicking the corresponding button below.

  
Bottom