home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / utils / assort.zip / CHOP31.DOC next >
Text File  |  1988-03-09  |  11KB  |  277 lines

  1.                                  CHOP
  2.                               Version 3.1
  3.  
  4. Author: Walter J. Kennamer                  Compuserve PPN: 74025,514
  5.  
  6.  
  7. CHOP breaks big files into smaller ones.  A number of options are
  8. supported to determine exactly where the breaks take place.  This
  9. version also allows you to extract a portion of a file.
  10.  
  11. More information about CHOP follows; but first, a word from my lawyers:
  12.  
  13. ------------------------------------------------------------------------------        
  14.    Copyright (c) 1986, 1987 Walter J. Kennamer.  All Rights Reserved.
  15.    
  16.    You are free to use, copy and distribute CHOP providing that:
  17.    
  18.            NO FEE IS CHARGED FOR USE, COPYING OR DISTRIBUTION.
  19.    
  20.            IT IS NOT MODIFIED IN ANY WAY.
  21.    
  22.            THIS DOCUMENTATION FILE (UNMODIFIED) ACCOMPANIES ALL COPIES.
  23.    
  24.    This program is provided AS IS without any warranty, expressed or
  25.    implied, including but not limited to fitness for a particular purpose.
  26.  
  27. ------------------------------------------------------------------------------        
  28.  
  29.   
  30. Usage:
  31.      A>CHOP infile [-switches]
  32.   
  33. "Infile" is a unambiguous file name (i.e., no wildcards are allowed). 
  34. The original input file will be unchanged.  The output files will have
  35. the same stem as the input file, but the extension will be numbered
  36. consecutively from 1.  For example, if you break FOO.BAR into three
  37. smaller files, FOO.BAR will be unchanged, and there will be three
  38. output files--FOO.1, FOO.2 and FOO.3.
  39.  
  40. Each switch requires a separate switch character (e.g., "-a -b" rather
  41. than "-ab").  Switch order does not matter, unless you enter mutually-
  42. exclusive switches, in which case the last one takes precedence.
  43.   
  44. Type CHOP by itself to see help.
  45.  
  46.   
  47. ==============================
  48. Command line options:
  49. ==============================
  50.         
  51. This table summarizes command line options.  Options can be preceded
  52. by a hyphen(-) or a slash(/) and can be upper or lower case.
  53.         
  54. These options determine how much of the file will be output
  55.         
  56. -Bx           Beginning byte to extract (default = 1).
  57. -Ex           Ending byte to extract (default = end of file).
  58.         
  59. These options determine how the file will be partitioned.  They
  60. are mutually exclusive.
  61.         
  62. -Px           Chop file into x pieces (default = 2).
  63. -Sxxx         Chop file into xxx-sized pieces.
  64.         
  65. These options determine where the data comes from and where it goes.
  66.         
  67. -Ifilename    Read input from "filename".
  68. -Odirectory   Send output to "directory".
  69. -T            Trample over existing files.
  70.  
  71. These options determine if the break will occur at a precise byte or at a
  72. set of characters near the computed boundary.  -R and -X are mutually
  73. exclusive.  -N, -A, -H, -L, -C and -W have no meaning if -X is selected. 
  74. -R is the default option.  The term "return character(s)" means the
  75. character(s) that determine where the file will be chopped.
  76.         
  77. -R           Try to chop at a "return" character (default is CR/LF).
  78.   -Nfoo      Define a sequence of "return" characters (e.g.,"foo").
  79.   -A         Chop after the "return" characters (default).
  80.   -H         Chop before the "return" characters.
  81.   -Lxxx      Limit search for "return" characters to xxx bytes.
  82.   -C         Make "return" characters case sensitive.
  83.   -W         Chop at each occurrence of the "return" string.
  84. -X           Chop at the exact computed byte.
  85.  
  86. -Mxxx        Define the maximum number of chops (default = 256).
  87. -Gxxx        Start output file numbering with xxx.
  88. -Q           Quiet.  Do not show program status on screen.
  89. -Z           Do not insert a Ctrl-Z EOF at end of each output file.
  90. -J           Pause for a keystroke between chops.
  91.  
  92. ==============================
  93. Terminology and other notes:
  94. ==============================
  95.  
  96. The term "computed break point" means the place in the file where the
  97. split would normally occur, if CHOP was not doing something special
  98. about return characters.  For example, if you have a file of 100,000
  99. bytes that is being split into 5 parts, the computed break points are
  100. at these bytes:
  101.    20,000
  102.    40,000
  103.    60,000
  104.    80,000
  105. You can force the breaks to occur exactly at these points by using the
  106. -X (exact) switch on the command line.  Or, you can let CHOP try to
  107. find a logical breaking point in the file (normally a carriage return /
  108. line feed).
  109.  
  110. The term "return string" or "return characters" means the sequence of
  111. one or more characters that defines a newline, or some other
  112. interesting boundary in the file.  CHOP assumes that you would prefer
  113. to split the file at a natural boundary, rather than just someplace in
  114. the middle.  By default, CHOP assumes the break should occur at a
  115. carriage return / line feed character sequence (CR LF -- Hex 0D 0A). 
  116. Thus, if CHOP plans to break the file at the 1000th byte, it will
  117. actually look a little ahead of byte 1000 to try to find a newline (CR
  118. LF) and split it there, rather than at byte 1000.
  119.  
  120. You can redefine the return string to be something else.  For example,
  121. Compuserve messages begin with the "#:" character sequence.  By
  122. defining this sequence as the return string, you instruct CHOP to split
  123. the file only between messages--no message would be split across CHOP
  124. output files.  You would define "#:" as the return string by using the
  125. switch "-n#:" on the command line (see examples).
  126.  
  127. CHOP ordinarily splits a file after the return string.  You can make
  128. the split happen before the return string by using the -h switch.  You
  129. would probably want to use this switch in the preceding Compuserve
  130. example since the "#:" characters mark the beginning of a message.  You
  131. would probably want them to be the first characters in a new file,
  132. rather than the last characters in the preceding file.
  133.  
  134. You can also limit how far CHOP is willing to search for the return
  135. string.  The -L parameter determines how many bytes forward of the
  136. computed break point CHOP looks for the return.  The default is 1000
  137. bytes.   If it cannot find the return string within the number of bytes
  138. specified with -L, CHOP breaks the file at the computed point. CHOP
  139. never breaks a file before the computed point.  As a consequence, the
  140. last CHOP output file will typically be a little smaller than the
  141. earlier ones: the differences between the computed break points and
  142. the actual return boundaries mount up.
  143.  
  144. The first byte of a file is byte 0 or byte 1.  The second byte is always
  145. byte 2.  In other words, CHOP always counts from 1.  if you specify byte
  146. 0, it assumes you mean the beginning byte.
  147.  
  148. CHOP will ordinarily decline to overwrite any existing files, but will
  149. display a message and halt instead.  If you want to trample over
  150. existing files (I had to use "trample"--T was the only letter left),
  151. use the -t switch on the command line.  If -t is specified, CHOP will
  152. write over any files that get in its way.
  153.  
  154. Use the -g switch to change the beginning file number.  For example, if
  155. you want to chop FOO.BAR into several pieces, but you want the first
  156. one to be numbered FOO.8, use the -g8 switch to set the starting
  157. number.
  158.  
  159.  
  160. ==============================
  161. Examples:
  162. ==============================
  163.  
  164. CHOP foo.bar
  165.  
  166. chops FOO.BAR into two pieces, FOO.1 and FOO.2.  If you do not use either
  167. the -P or -S switches, CHOP assumes you want to split the file into two 
  168. pieces.
  169.  
  170.  
  171. CHOP foo.bat -p5
  172.  
  173. chops the foo.bat program into five files of approximately equal size. 
  174. The breaks take place after a CR/LF pair.
  175.  
  176.         
  177. CHOP foo.bat -s2000 -x
  178.  
  179. chops foo.bat into 2000-byte pieces.  The first chop occurs exactly at
  180. byte 2000.  Note that the output file will actually have 2001 bytes,
  181. counting the control-Z added to the file (though you can suppress it
  182. with the -z switch).
  183.  
  184.         
  185. CHOP foo.bat -e2000
  186.  
  187. copies the first 2000 bytes of foo.bat to FOO.1.  By default, copying
  188. begins at the first byte of the file. 
  189.  
  190.         
  191. CHOP foo.bat -e2000 -p2
  192.  
  193. puts the first 2000 bytes of foo.bat into 2 files of about 1000 bytes each.
  194.  
  195.         
  196. CHOP foo.bat -b3000 -e3999 -p2 -r
  197.  
  198. puts the 1000 bytes in foo.bat between byte 3000 and 3999 into 2 files. 
  199. The chop will occur at the first CR/LF pair after byte 3500.
  200.  
  201.         
  202. CHOP foo.bat -s20000 -nMSG: -oD:\CHOPOUT -g5 -c
  203.  
  204. chops foo.bat into pieces of approximately 20,000 bytes.  The first chop
  205. will occur immediately after the first occurrence of the string "MSG:"
  206. (case sensitive because of -c) after byte 20000.  The output files will be
  207. D:\CHOPOUT\FOO.5, FOO.6, etc.
  208.  
  209.  
  210. CHOP -id:\pdq\cserv.thd -p10 -n#: -h -l2000
  211.  
  212. chops d:\pdq\cserv.thd into about 10 pieces, with the breaks occurring
  213. immediately before the character string "#:" (used by Compuserve forum
  214. software to designate a new message).  CHOP will search up to 2000 bytes
  215. past the computed break point for the "#:" string.  If it cannot find
  216. "#:" within 2000 bytes, it will give up and break at the computed point.
  217.  
  218.         
  219. CHOP cserv.thd -h -n#: -w -t
  220.  
  221. chops cserv.thd into many files--one for each occurrence of the "#:"
  222. string.  The -w switch implies an unlimited search limit and overrides
  223. the -P, -S and -X switches.  Overwrite any files (CSERV.1, CSERV.2,
  224. etc.) that are already there.
  225.         
  226.  
  227. CHOP program.pas -nPROCEDURE -w -h
  228.  
  229. chops the program.pas Pascal file into many files--one for each
  230. procedure.  After executing this command, each of the procedures in
  231. "program.pas" will be in a separate file.
  232.  
  233.  
  234. CHOP foo.bar -n$0C -p3
  235.  
  236. This example shows how to put hex codes in the "return" string.  The
  237. codes must be exactly two digits (i.e., precede single digit hex codes
  238. with a 0) and must be preceded by a dollar sign.  This example causes
  239. foo.bar to be chopped into three pieces, with the chop taking place at a
  240. hex 0C character (ASCII decimal 12, or formfeed).
  241.  
  242.  
  243. FOR %1 in (*.TXT) DO CHOP %1 -p4
  244.  
  245. This example illustrates how to use the batch FOR command to CHOP a
  246. series of files as specified by the wildcard (*.TXT).  In this case,
  247. each .TXT file will be chopped into four pieces of approximately equal
  248. size.
  249.  
  250.  
  251. ==============================
  252. Rejoining Chopped Files
  253. ==============================
  254.  
  255. You can use the DOS copy command to rejoin chopped files.  For example,
  256. this command rejoins two text files--FOO.1 and FOO.2--to recreate the
  257. original FOO.BAR file. 
  258.  
  259.      COPY FOO.1/a+FOO.2 FOO.BAR
  260.  
  261. If FOO.BAR, FOO.1 and FOO.2 are binary files, use the /b switch with the
  262. COPY command:
  263.  
  264.      COPY FOO.1/b+FOO.2 FOO.BAR
  265.  
  266. The /b switch causes DOS to treat control-Z characters as legitimate
  267. data (instead of EOF marks) when the files are joined.
  268.  
  269. ==============================
  270. Support
  271. ==============================
  272.  
  273. If you have any problems with CHOP or any suggestions about how to
  274. improve it, please contact me on Compuserve (PPN 74025,514) or write to
  275. me at 1801 E. 12th., Apt 1118, Cleveland, OH  44114. 
  276.  
  277.