[an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] 24x7 Script Archive


Use LineCopy utility to copy portions of text files in non-blocking mode.

LineCopy utility provides for Windows what head and tail utilities provide for Unix systems. Files are copied in shared read-write mode so that they can be accessible for read and update by other programs during LineCopy processing.

Download LineCopy.exe (16 KB).

The LineCopy utility can be used for the following text copy operations.

  • Copy entire files in non-blocking mode.
  • It can copy only first N lines from the start.
  • Copy only last N lines from the end.
  • Copy all lines after first N lines (in other words, skip first N lines).
  • Copy all lines before last N lines (in other words, skip last N lines).
  • Copy only first N and last M lines (in other words, skip middle part between lines N and M).
  • Copy only lines between N and M (in other words, skip first N lines and also skip last M lines).

Here is description of the supported command line parameters:

Usage: LineCopy source destination [/M mode] [/S start-line] [/E end-line]

Command line parameters:

source Name of the source file
destination Name of the destination file

Optional parameters:
/M mode copy mode, one of the following: 1, 2, 3, 4, 5, 6
Mode 0: (default) copy entire file.
Mode 1: copy first start-line lines of a file. /S parameter must be specified.
Mode 2: copy last end-line lines of a file. /E parameter must be specified.
Mode 3: copy file skipping first start-line lines. /S parameter must be specified.
Mode 4: copy file skipping last end-line lines. /E parameter must be specified.
Mode 5: copy first start-line lines and last end-line lines skipping all lines in between. Both /S and /E parameters must be specified.
Mode 6: copy all lines between start-line and end-line lines. Both /S and /E parameters must be specified.
/S start-line starting line, the usage depends on the value of the Mode parameter.
/E end-line ending-line, the usage depends on the value of the Mode parameter.

Run LineCopy.exe without parameters from the DOS command prompt to see full description of the supported parameters.

Examples:

  1. To copy first 5 lines of account.txt file and save them into header.txt run the following command
    LineCopy c:\accounts\account.txt c:\accounts\header.txt /M 1 /S 5
  2. To copy contents of report.txt file skipping first 3 lines containing the report column header and last 2 lines containing report totals and save the result into data.txt run the following command
    LineCopy c:\data\report.txt c:\data\data.txt /M 6 /S 3 /E 2