Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: ChopShop Span Spanning File Splitter large files
; ChopShop Heavyweight MH Feb 6, 2002 AddExtender("wwhug34i.dll") ;Check for function support if StrUpper(Version()) < "2002B" Message("Sorry","This script needs WinBatch 2002B or newer") exit endif ;=========================================================================================== ;GUI Interface splitdefault="1.44 MB Floppy" inifile="www-prod.ini" inisect="ChopShop2" splitinfo="720KB Floppy|1.44MB Floppy|100 MB Zip|660MB CDROM|1GB JAZ|2GB JAZ|Other" ;sizes not tested (yet) splitdata="720000|1440000|100000000|660000000|1000000000|2000000000|-1" splitinfo=StrReplace(splitinfo,"|",@tab) splitdata=StrReplace(splitdata,"|",@tab) fn=IniReadpvt(inisect,"fn","",inifile) if FileExist(fn)==@FALSE fn=0 fsize=0 else fsize=FileSize(fn,1) endif destdir=IniReadPvt(inisect,"destdir","C:\",inifile) dfree=DiskFree(destdir,1) splitselect=IniReadPvt(inisect,"splitselect","1.44MB Floppy",inifile) HugeSplitSize=IniReadPvt(inisect,"splitsize","1440000",inifile) while 1 spdat=splitselect MyDialogFormat=`WWWDLGED,5.0` MyDialogCaption=`ChopShop Heavyweight` MyDialogX=55 MyDialogY=74 MyDialogWidth=339 MyDialogHeight=117 MyDialogNumControls=12 MyDialog01=`8,4,49,DEFAULT,PUSHBUTTON,DEFAULT,"Source File",2` MyDialog02=`65,8,259,DEFAULT,VARYTEXT,fn,"fn"` MyDialog03=`8,41,49,DEFAULT,PUSHBUTTON,DEFAULT,"Dest Folder",3` MyDialog04=`64,43,256,DEFAULT,VARYTEXT,destdir,"destdir"` MyDialog05=`9,78,49,DEFAULT,PUSHBUTTON,DEFAULT,"Split Size",4` MyDialog06=`65,81,252,DEFAULT,VARYTEXT,spdat,"splitselect"` MyDialog07=`86,100,49,DEFAULT,PUSHBUTTON,DEFAULT,"&OK",1` MyDialog08=`169,100,49,DEFAULT,PUSHBUTTON,DEFAULT,"&Cancel",0` MyDialog09=`65,20,46,DEFAULT,STATICTEXT,DEFAULT,"Filesize"` MyDialog10=`113,20,86,DEFAULT,VARYTEXT,fsize,"fs"` MyDialog11=`64,56,51,DEFAULT,STATICTEXT,DEFAULT,"Freespace on drive"` MyDialog12=`116,56,81,DEFAULT,VARYTEXT,dfree,"dfree"` ButtonPushed=Dialog("MyDialog") switch ButtonPushed case 1 ; OK if fn=="" Pause("Sorry","Please enter file name") endif break case 2 ; source file fn=AskFileName("Select fileto split", "C:\", "All Files|*.*", "*.*", 1 ) fsize=FileSize(fn,1) break case 3 ; dest folder destdir=AskDirectory("Select Destination Folder","",destdir,"Create Folder?",1+2) if DirExist(destdir)==@FALSE then DirMake(destdir) dfree=DiskFree(destdir,1) break case 4 ; split size spdat=AskItemList("Choose Split Size",splitinfo,@tab,@unsorted,@single) a=ItemLocate(spdat,splitinfo,@tab) HugeSplitSize=ItemExtract(a,splitdata,@tab) if HugeSplitSize== -1 while 1 HugeSplitSize=AskLine("ChopShop Heavyweight","Enter split size in bytes",1440000) if strlen(StrClean(HugeSplitSize,"0123456789","",0,2)) == strlen(HugeSplitSize) then break Pause("Sorry. Must enter a number",strcat(HugeSplitSize,@crlf,"is not a number")) endwhile splitselect=strcat(HugeSplitSize," bytes") else splitselect=spdat endif break end switch if ButtonPushed != 1 then continue FileDelete(strcat(destdir,FileRoot(fn),".#*")) ;Lets take a guess at seeing if it might fit.... excess=huge_Subtract(DiskFree(destdir,1),fsize) if strindex(excess,"-",0,@fwdscan) Pause("Sorry",strcat(fn,@crlf, "will simply not fit in",@crlf,destdir)) continue endif if fn!="" && destdir!="" && HugeSplitSize!="" then break endwhile IniWritepvt(inisect,"fn",fn,inifile) IniWritepvt(inisect,"destdir",destdir,inifile) IniWritepvt(inisect,"splitselect",splitselect,inifile) IniWritepvt(inisect,"splitsize",HugeSplitSize,inifile) ; End GUI ;================================================================================================= ;user specifiable parameters above BoxOpen("ChopShop Heavyweight","Initializing") HugeFileSize=FileSize(fn,1) ; get filesize as a hugenumber bufsize=100000001 ; 100MB - not to exceed 2GB GB limit normal number OK bb=BinaryAlloc(bufsize) ;compute how many buffers required for splitssize bufcount=Int(ceiling(huge_divide(HugeSplitSize,bufsize))) ;compute how many splits required for the file splitcount=Int(ceiling(huge_divide(HugeFileSize,HugeSplitSize))) HugeFileOffset="0" ; a hugenumber HugeTotalBytesProcessed="0" ; another hugenumber used as a check for ss=1 to splitcount HugeSplitOffset="0" ; a hugenumber splitfn=(strcat(destdir,FileRoot(fn),".#",strfixleft(ss,0,4))) for xx=1 to bufcount text=strcat(fn,@crlf,"Working on split ",ss," of ",splitcount,@crlf,"Processing part ",xx," of ",bufcount) BoxText(text) BoxTitle(strcat("ChopShop Heavyweight: ",((ss-1)*bufcount)+xx,"/",(splitcount*bufcount))) BinaryEODSet(bb,0) if xx==bufcount then readsize=huge_Subtract(HugeSplitSize,huge_multiply( (xx-1) , bufsize)) else readsize=bufsize bytesread=BinaryReadEx(bb,0,fn,HugeFileOffset,readsize) if bytesread==0 then break BinaryWriteEx(bb,0,splitfn,HugeSplitOffset,bytesread) HugeSplitOffset=huge_Add(HugeSplitOffset,bytesread) HugeFileOffset=huge_add(HugeFileOffset,bytesread) HugeTotalBytesProcessed=huge_add(HugeTotalBytesProcessed,bytesread) next xx next ss ;Build bat file to glue it back together. if strindex(FileRoot(fn)," ",0,@fwdscan)+strindex(FileExtension(fn)," ",0,@fwdscan) q='"' else q='' endif frbat=(strcat(destdir,FileRoot(fn),"_Rebuild.bat")) hh=FileOpen(frbat,"write") ff=FileRoot(fn) line=strcat("copy /b ",q,FileRoot(fn),".#0001",q) for xx=2 to splitcount line=strcat(line,"+",q,FileRoot(fn),".#",strfixleft(xx,0,4),q) next line=strcat(line," ",q,FileRoot(fn),".",FileExtension(fn),q) FileWrite(hh,line) FileClose(hh) BinaryFree(bb) Message("All","doned")
Article ID: W15281
File Created: 2002:09:05:13:51:02
Last Updated: 2002:09:05:13:51:02