How to do things
AI Noob vs. Pro

List biggest files
List newest files
Show subdir sizes
Search in files
Replace word in files
List dir differences
Send files in LAN

Free Open Source:

Swiss File Knife

a command line
multi function tool.

remove tabs
list dir sizes
find text
filter lines
find in path
collect text
instant ftp or
http server
file transfer
send text
patch text
patch binary
run own cmd
convert crlf
dup file find
md5 lists
fromto clip
hexdump
split files
list latest
compare dirs
save typing
trace http
echo colors
head & tail
dep. listing
find classes
speed shell
zip search
zip dir list

Depeche View
Source Research
First Steps

windows GUI
automation

command line
file encryption

free external tools,
zero install effort,
usb stick compliant:

zip and unzip
diff and merge
reformat xml
reformat source

cpp sources

log tracing
mem tracing
hexdump
using printf

articles

embedded
stat. c array
stat. java array
var. c array
var. java array
view all text
as you type
surf over text
find by click
quick copy
multi view
find nearby
fullscreen
bookmarks
find by path
expressions
location jump
skip accents
clip match
filter lines
edit text
highlight
load filter
hotkey list
receive text
send in C++
send in Java
smooth scroll
touch scroll
fly wxWidgets
fly over Qt
search Java

copy byte blocks from one file into another file, with a specified offset and length using the free sfk partcopy command for the Windows, Mac OS X, Linux and Raspberry Pi command line.
  • Download the free Swiss File Knife Base from Sourceforge.
  • Open the Windows CMD command line, Mac OS X Terminal or Linux shell.
  • OS X : type mv sfk-mac-64.exe sfk and chmod +x sfk then ./sfk
  • Linux: type mv sfk-linux-64.exe sfk and chmod +x sfk then ./sfk. OS X and Linux syntax may differ, check the help within the tool.
sfk partcopy infile offset length outfile [offset2] [-yes]
sfk partcopy infile -allfrom startoffset outfile ...
sfk partcopy infile -fromto startoffset endoffset outfile ...

reads a block of bytes from infile at specified offset,
writing them into another file. if offset2 is specified,
outfile is not created, but the bytes are used to overwrite
other bytes within the output file.

by default, the command simulates, checking file lengths
but not copying any data. add -yes to really copy contents.

negative offsets can be used, to specify positions
relative to the file end instead of file start.

if output offset2 + length is larger than output file size,
the output file is extended. use -noext to avoid this.

length syntax:
    100000   ,  100k        = 100000 bytes
    2000000k , 2000m , 2g   = 2 giga-bytes

options
   -quiet    do not print number of copied bytes.
   -verbose  tell how offsets and lengths are calculated.
             type directly after "partcopy" for all infos.
   -fromto   use this if you don't want to specify offset
             and length for the input, but a start and end
             offset. end offset is exclusive, i.e. length
             is end minus start.
   -fromtoinc  same as -fromto but including end offset,
             so copy length is (end - start) + 1
   -allfrom  copy all from start offset, until end of file.
   -noext    do not allow an extension of the output file,
             stop with error if writing beyond output end.
   -append   if given after output filename, data is added
             to the end of the output file.

see also
   sfk setbytes  write a byte sequence into a file
   sfk hexdump   show binary file contents as hexdump
   sfk hexfind   search data in binary files
   sfk hextobin  convert hexdump to binary

web reference
   http://stahlworks.com/sfk-partcopy

examples
   sfk partcopy first.dat 10000 50 second.dat 500000
      copies 50 bytes from first.dat at offset 10000 into
      second.dat (which should exist) at offset 500000

   sfk partcopy first.dat -fromto 0x2710 0x2950 second.dat
      input start and end offset in hexadecimal numbers,
      output file is created (no output offset given).

   sfk partcopy in.txt -allfrom 1000 out.txt -append
      take from in.txt all data from offset 1000 until end
      and append that to out.txt.

   sfk partcopy in.dat -fromto -1000 -900 out.dat -500
      take from in.dat all bytes from end minus 1000
      until end minus 900, i.e. a 100 bytes block, and
      write this into output at end minus 500 bytes.
      (type -verbose after partcopy for details.)
 
sfk partcopy infile offset length outfile 
   [offset2] [-yes]
sfk partcopy infile -allfrom startoffset 
                      outfile ...
sfk partcopy infile -fromto startoffset 
                      endoffset outfile ...
                      

reads a block of bytes from infile at 
specified offset, writing them into
another file. if offset2 is specified,
outfile is not created, but the bytes are
used to overwrite other bytes within the
output file.

by default, the command simulates, 
checking file lengths
but not copying any data. add -yes to 
really copy contents.

negative offsets can be used, to specify 
positions
relative to the file end instead of file 
start.

if output offset2 + length is larger than 
                   output file size,
the output file is extended. use -noext to 
avoid this.

length syntax:
    100000   ,  100k        = 100000 bytes
    2000000k , 2000m , 2g   = 2 giga-bytes

options
   -quiet    do not print number of copied 
             bytes.
   -verbose  tell how offsets and lengths 
             are calculated. type directly
             after "partcopy" for all infos.
             
   -fromto   use this if you don't want to 
             specify offset and length for
             the input, but a start and end
             offset. end offset is
             exclusive, i.e. length is end
             minus start.
   -fromtoinc  same as -fromto but 
               including end offset,
             so copy length is (end - 
             start) + 1
   -allfrom  copy all from start offset, 
             until end of file.
   -noext    do not allow an extension of 
             the output file, stop with
             error if writing beyond output
             end.
   -append   if given after output filename,
             data is added to the end of
             the output file.

see also
   sfk setbytes  write a byte sequence 
                 into a file
   sfk hexdump   show binary file 
                 contents as hexdump
   sfk hexfind   search data in 
                 binary files
   sfk hextobin  convert hexdump to binary

web reference
   http://stahlworks.com/sfk-partcopy

examples sfk partcopy first.dat 10000 50 second.dat 500000 copies 50 bytes from first.dat at offset 10000 into second.dat (which should exist) at offset 500000 sfk partcopy first.dat -fromto 0x2710 0x2950 second.dat input start and end offset in hexadecimal numbers, output file is created (no output offset given). sfk partcopy in.txt -allfrom 1000 out.txt -append take from in.txt all data from offset 1000 until end and append that to out. txt. sfk partcopy in.dat -fromto -1000 -900 out.dat -500 take from in.dat all bytes from end minus 1000 until end minus 900, i.e. a 100 bytes block, and write this into output at end minus 500 bytes. (type -verbose after partcopy for details.)

you are viewing this page in mobile portrait mode with a limited layout. turn your device right, use a desktop browser or buy the sfk e-book for improved reading.

 
sfk is a free open-source tool, running instantly without installation efforts. no DLL's, no registry changes - just get sfk.exe from the zip package and use it (binaries for windows, linux and mac are included).

 

the Endless Image 🍣 Sushi