Jump to content

Recommended Posts

Posted (edited)
$input = $CmdLine[1]

$bytes = 1000000    ; 1000000 for 1 MB, 1000 for 1 KB
$size  = FileGetSize($input)
$file = fileopen($input, 16)
$max =  ceiling($size / $bytes)

for $i = 1 to $max
   $data = fileread($file, $bytes)
   $output = $input & '_' & $i & 'of' & $max
   filewrite($output, $data)
next

^file split
file path for a 20MB "video.mp4" is input, it will be output as "video.mp4_1of20", "video.mp4_2of20", etc. change $bytes to affect the split files size, this example made them 1MB (10^6 bytes)

 

$input = $CmdLine[1]
$name  = stringtrimright($input, 1 + stringlen($input) - stringinstr($input, '_', 0, -1))

$split = stringsplit($input, 'of', 3)
$max   = $split[ubound($split) - 1]

for $i = 1 to $max
   $in   = $name & '_' & $i & 'of' & $max
   $file = fileopen($in, 16)
   $data = fileread($file)
   fileclose($file)
   filedelete($in)
   filewrite($name, $data)
next

^ file join
file path for any of the "video.mp4_Xof20" segments is input. the "video.mp4_Xof20" segments are read and written to "video.mp4" and then deleted, leaving the newly joined "video.mp4" in the end

 

i made this today because i had a big file that i couldn't really open. i split it into 1000 chunks to make processing and stuff easier. i've also used it to split files to just under 25MB segments so i can attach and mail big files over gmail which is silly but it worked

Edited by lIlIIlIllIIIIlI

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...