Sign in to follow this  
Followers 0
torels

Split File in Chunks

6 posts in this topic

Hi there

The title of the topic says it all... how do I split a file in a number of smaller files (of hte same size) ?

thanks in advance :)


Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Share this post


Link to post
Share on other sites



Very fast and free is the tool ChainSaw.exe.

Files > 4Gig are fine.

Simply drag/drop the files on the Icon. Maybe it can use command line params, pls check out yourself.

a merge tools is also provided.

Regards, Rudi.


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites

$B = 0
$KB = 1
$MB = 2
$GB = 3
$TB = 4


$iPartSize = Lenght(1,$MB)

$sPath = FileOpenDialog("Open file to split",@DesktopDir,"All files (*.*)")

If @error Then Exit

$hFile = FileOpen($sPath,16)
$sRead = FileRead($hFile)
FileClose($hFile)

$iTotalLenght = BinaryLen($sRead)

$iPartCount = $iTotalLenght/$iPartSize

$sPathSplit = StringSplit($sPath,"\")

DirCreate($sPath&".part")

For $i = 1 to Ceiling($iPartCount)
    
    $hPartFile = FileOpen($sPath&".part\"&$sPathSplit[$sPathSplit[0]]&"."&$i&".part",16+2)
    FileWrite($hPartFile, BinaryMid($sRead,($i-1)*$iPartSize+1,$iPartSize))
    FileClose($hPartFile)
    
Next


Func Lenght($iLen, $iType)
    Return 1024^$iType * $iLen
EndFunc

Share this post


Link to post
Share on other sites

$B = 0
$KB = 1
$MB = 2
$GB = 3
$TB = 4


$iPartSize = Lenght(1,$MB)

$sPath = FileOpenDialog("Open file to split",@DesktopDir,"All files (*.*)")

If @error Then Exit

$hFile = FileOpen($sPath,16)
$sRead = FileRead($hFile)
FileClose($hFile)

$iTotalLenght = BinaryLen($sRead)

$iPartCount = $iTotalLenght/$iPartSize

$sPathSplit = StringSplit($sPath,"\")

DirCreate($sPath&".part")

For $i = 1 to Ceiling($iPartCount)
    
    $hPartFile = FileOpen($sPath&".part\"&$sPathSplit[$sPathSplit[0]]&"."&$i&".part",16+2)
    FileWrite($hPartFile, BinaryMid($sRead,($i-1)*$iPartSize+1,$iPartSize))
    FileClose($hPartFile)
    
Next


Func Lenght($iLen, $iType)
    Return 1024^$iType * $iLen
EndFunc
If I want to create file again from splitted files, what should I do?

Thanks in advance!


When the words fail... music speaks

Share this post


Link to post
Share on other sites

Hello,

I know that writing own scripts is fun and educational,

but if you need to split laaarge files, you could use the winrar

command line tool to split/rejoin these files.

It can be found at http://www.win-rar.com/download.html.

Here is an example batch file to split files with rar.exe:

@echo off
:: --------------------------------------------------------------------------
:: file path\name to split
set file=%1
:: filename only, dont touch
set fName=%~n1
:: output directory, path to put rar split files
set out=.\out
:: rar binary
set rar=.\bin\rar.exe
:: output split size, in rar size format
set size=32000k
::set size=12000k
:: 0-5, 0=store
set compression=0
: ---------------------------------------------------------------------------
if "%file%"=="" goto noparam
if not exist %file% goto nofile

call :log start split on file %~n1, size: %size%
%rar% a -v%size% -m%compression% %out%\%fName% %file%
call :log done split file %~n1
goto end


:noparam
call :log Error: no path\file name parameter given to splice
goto end

:nofile
call :log Error: file %file% not found
goto end

:log
echo %DATE% %TIME% - %*
goto :EOF

:end

Usage: scp_rarSplit.cmd drive:\path\to\bigfile.ext

The split files go to %out%, configured in the batch file.

Just look at the first few lines in the batch, to configure it

for your purposes.

ciao

Xandl

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0