----^--->
/\

//\\
//The\
/Sy
stem\
////
Guard
\

In the mount of the LORD it shall be seen. Genesis 22:14

File_Number_Lines

Booming Or Fuming? | MasterCatalog | ntlib (FREE) | NTCmdLib | MtCmds | Scripts | Almost Free | TheGuardBook | Help

 

Library
Resources

Constants | Functions | GlobalSwitches | GuardNotes | Command Shorthand | MountCommands | Procedures
Procedures   File_Number_Lines | Parse_Command_Line_Switches | System_Info

:FNL (File_Number_Lines)

Description

Number the lines in a text file while padding the line numbers with 0's to a fixed column-width.  Supports custom delimiters between line numbers and line content.  This enables any text file to be edited by line number, and then to be easily "de-numbered", all within the confines of a shell script.

Syntax

At the Command Prompt

C:\>NTCmdLib   :[FNL|File_Number_Lines] [/NoPad] [drive:][path]FileName ["CustomDelimiter"]

In a Script

CALL NTCmdLib   :[FNL|File_Number_Lines] [/NoPad]
[drive:][path]FileName ["CustomDelimiter"]
%.Call%   :[FNL|File_Number_Lines] [/NoPad]
[drive:][path]FileName ["CustomDelimiter"]

Parameters and Switches

/NoPad   Suppresses the padding of line number with 0's (0001, 0002, etc.)
[drive:][path]filename   Specifies a file to number (also accepts UNC paths such as \\server\share\[path\]filename)
"CustomDelimiter"   Optional delimiter to place between the line numbers and line contents.  Defaults to ". " {dot space}

Errorlevels, Output Variables and Custom Mount/\Commands

Name

 

Value

  Description/Contents

_FNL

 

Status Message

  Variable containing a message indicating the outcome of the job.

_FNL_File

 

FileName.ext.numbered.txt

  Variable containing the full filespec of the numbered output file

_FNL_Lines

 

nnn

  The total number of lines found in the input file

.FNL_View

 

session-specific script code

  Display the numbered output file

.FNL_eView

 

session-specific script code

  Display the numbered output file (escapified!)

.FNL_Delete

 

session-specific script code

  Delete the numbered output file

Examples, Notes and Instructions

Notes

  • Output is displayed to STDOUT, errors to STDERR
  • To suppress console display, use the library GlobalSwitch /Quiet (or simply /q)

    NTCmdLib /Q TaskID /TaskSwitches Parameters

    CALL NTCmdLib /Q TaskID /TaskSwitches Parameters

    %.Call% /Q TaskID /TaskSwitches Parameters

  • Maximum number of input lines = 999999999 (one Billion minus 1)
  • Maximum size of a single line = 1023 characters (excess characters will be truncated)
     

Example 1 - standard usage

NTCmdLib :FNL "FileName.Ext"

Line numbers are padded with 0's to match the largest
number needed, based on the input file size.

001. This is the first line of text
002. This is the second line of text
|||.
010. This is the tenth line of text
|||.
122. This is the one-hundred twenty-second line of text

Example 2 - without padded line numbers

NTCmdLib :FNL /NoPad "FileName.Ext"

If /NoPad switch is specified, line numbers are not padded with 0's.

1. This is the first line of text
2. This is the second line of text
|
10. This is the tenth line of text
|
568. This is the five-hundred sixty-eighth line of text
 

Example 3 - with padded line numbers and a custom delimiter

NTCmdLib :FNL "..: " "FileName.Ext"

If using a CustomDelimiter = "..: " (dot dot colon space),
line numbers are separated from the content using the specified delimiter.

001..: This is the first line of text
002..: This is the second line of text
|||..:
010..: This is the tenth line of text
|||..:
201..: This is the two-hundred first line of text

Example 4 - Interactively, at the command prompt

NT
2K
XP
K3
C:\GuardPost>ntcmdlib /i
  ^   =========================================================================
 /!\   NTCmdLib.cmd 2004.03.14 NT/2K/XP/K3 ("Almost Freeware" at $9 or less!)
/LIB\ =========================================================================
----------------------------------------
/\ WELCOME TO THE TOP OF THE MOUNT! /\
----------------------------------------
   CmdShorthand___________: 17
   Constants______________: 30
   Functions______________: 9
   GlobalSwitches_________: 7
   GuardNotes_____________: 1
   MountCommands__________: 282
   Procedures_____________: 3
   ------------------------------
   Total Library Resources: 349
_____________________________________________________________________________
[Fri 03/19/2004 12:01:49] NTCmdLib Initialization Complete!

C:\GuardPost>dir %systemroot%\system32\w*.exe
 Volume in drive E is Mount
 Volume Serial Number is 0011-AB90

 Directory of E:\XPPRO\system32

08/23/2001 07:00 AM             49,664 w32tm.exe
08/29/2002 02:41 AM             60,416 wextract.exe
08/23/2001 07:00 AM            414,720 wiaacmgr.exe
08/23/2001 07:00 AM             35,328 winchat.exe
08/23/2001 07:00 AM              8,192 winhlp32.exe
08/29/2002 02:41 AM            516,608 winlogon.exe
08/23/2001 07:00 AM            119,808 winmine.exe
08/23/2001 07:00 AM             11,776 winmsd.exe
08/23/2001 07:00 AM              2,112 winspool.exe
08/23/2001 07:00 AM              4,096 winver.exe
02/28/2003 05:26 PM            171,792 wjview.exe
08/29/2002 02:41 AM             77,824 wmpstub.exe
08/23/2001 07:00 AM              2,736 wowdeb.exe
08/23/2001 07:00 AM             10,368 wowexec.exe
08/23/2001 07:00 AM             31,232 wpabaln.exe
08/23/2001 07:00 AM             29,184 wpnpinst.exe
08/23/2001 07:00 AM              5,632 write.exe
08/23/2001 07:00 AM            118,834 wscript.exe
01/31/2004 12:40 AM            148,792 wuauclt.exe
08/23/2001 07:00 AM             32,256 wupdmgr.exe
             20 File(s)       1,851,370 bytes
              0 Dir(s)    3,090,051,072 bytes free

C:\GuardPost>dir %systemroot%\system32\w*.exe > test.txt

C:\GuardPost>type test.txt
 Volume in drive E is Mount
 Volume Serial Number is 0011-AB90

 Directory of E:\XPPRO\system32

08/23/2001 07:00 AM             49,664 w32tm.exe
08/29/2002 02:41 AM             60,416 wextract.exe
08/23/2001 07:00 AM            414,720 wiaacmgr.exe
08/23/2001 07:00 AM             35,328 winchat.exe
08/23/2001 07:00 AM              8,192 winhlp32.exe
08/29/2002 02:41 AM            516,608 winlogon.exe
08/23/2001 07:00 AM            119,808 winmine.exe
08/23/2001 07:00 AM             11,776 winmsd.exe
08/23/2001 07:00 AM              2,112 winspool.exe
08/23/2001 07:00 AM              4,096 winver.exe
02/28/2003 05:26 PM            171,792 wjview.exe
08/29/2002 02:41 AM             77,824 wmpstub.exe
08/23/2001 07:00 AM              2,736 wowdeb.exe
08/23/2001 07:00 AM             10,368 wowexec.exe
08/23/2001 07:00 AM             31,232 wpabaln.exe
08/23/2001 07:00 AM             29,184 wpnpinst.exe
08/23/2001 07:00 AM              5,632 write.exe
08/23/2001 07:00 AM            118,834 wscript.exe
01/31/2004 12:40 AM            148,792 wuauclt.exe
08/23/2001 07:00 AM             32,256 wupdmgr.exe
             20 File(s)       1,851,370 bytes
              0 Dir(s)    3,090,051,072 bytes free

C:\GuardPost>ntcmdlib :fnl test.txt

  ^   =========================================================================
 /!\    NTCmdLib.cmd 2004.03.14 NT/2K/XP/K3 ("Almost Freeware" at $9 or less!)
/LIB\ =========================================================================

 Processing exceptions...
 Numbering main file...
        1 file(s) copied.
_FCOUNT=27
_FNL_File=test.txt.numbered.txt

C:\GuardPost>%.fnl_view%
01.  Volume in drive E is Mount
02.  Volume Serial Number is 0011-AB90
03. 
04.  Directory of E:\XPPRO\system32
05. 
06. 08/23/2001 07:00 AM             49,664 w32tm.exe
07. 08/29/2002 02:41 AM             60,416 wextract.exe
08. 08/23/2001 07:00 AM            414,720 wiaacmgr.exe
09. 08/23/2001 07:00 AM             35,328 winchat.exe
10. 08/23/2001 07:00 AM              8,192 winhlp32.exe
11. 08/29/2002 02:41 AM            516,608 winlogon.exe
12. 08/23/2001 07:00 AM            119,808 winmine.exe
13. 08/23/2001 07:00 AM             11,776 winmsd.exe
14. 08/23/2001 07:00 AM              2,112 winspool.exe
15. 08/23/2001 07:00 AM              4,096 winver.exe
16. 02/28/2003 05:26 PM            171,792 wjview.exe
17. 08/29/2002 02:41 AM             77,824 wmpstub.exe
18. 08/23/2001 07:00 AM              2,736 wowdeb.exe
19. 08/23/2001 07:00 AM             10,368 wowexec.exe
20. 08/23/2001 07:00 AM             31,232 wpabaln.exe
21. 08/23/2001 07:00 AM             29,184 wpnpinst.exe
22. 08/23/2001 07:00 AM              5,632 write.exe
23. 08/23/2001 07:00 AM            118,834 wscript.exe
24. 01/31/2004 12:40 AM            148,792 wuauclt.exe
25. 08/23/2001 07:00 AM             32,256 wupdmgr.exe
26.              20 File(s)       1,851,370 bytes
27.               0 Dir(s)    3,090,051,072 bytes free

C:\GuardPost>%.ForAll% %A in ('%.FNL_eView%') DO @ECHO:This is line %A
This is line 01.  Volume in drive E is Mount
This is line 02.  Volume Serial Number is 0011-AB90
This is line 03. 
This is line 04.  Directory of E:\XPPRO\system32
This is line 05. 
This is line 06. 08/23/2001 07:00 AM             49,664 w32tm.exe
This is line 07. 08/29/2002 02:41 AM             60,416 wextract.exe
This is line 08. 08/23/2001 07:00 AM            414,720 wiaacmgr.exe
This is line 09. 08/23/2001 07:00 AM             35,328 winchat.exe
This is line 10. 08/23/2001 07:00 AM              8,192 winhlp32.exe
This is line 11. 08/29/2002 02:41 AM            516,608 winlogon.exe
This is line 12. 08/23/2001 07:00 AM            119,808 winmine.exe
This is line 13. 08/23/2001 07:00 AM             11,776 winmsd.exe
This is line 14. 08/23/2001 07:00 AM              2,112 winspool.exe
This is line 15. 08/23/2001 07:00 AM              4,096 winver.exe
This is line 16. 02/28/2003 05:26 PM            171,792 wjview.exe
This is line 17. 08/29/2002 02:41 AM             77,824 wmpstub.exe
This is line 18. 08/23/2001 07:00 AM              2,736 wowdeb.exe
This is line 19. 08/23/2001 07:00 AM             10,368 wowexec.exe
This is line 20. 08/23/2001 07:00 AM             31,232 wpabaln.exe
This is line 21. 08/23/2001 07:00 AM             29,184 wpnpinst.exe
This is line 22. 08/23/2001 07:00 AM              5,632 write.exe
This is line 23. 08/23/2001 07:00 AM            118,834 wscript.exe
This is line 24. 01/31/2004 12:40 AM            148,792 wuauclt.exe
This is line 25. 08/23/2001 07:00 AM             32,256 wupdmgr.exe
This is line 26.              20 File(s)       1,851,370 bytes
This is line 27.               0 Dir(s)    3,090,051,072 bytes free

C:\GuardPost>set _
_FNL=[test.txt] Numbered 27 lines to [test.txt.numbered.txt]
_FNL_File=test.txt.numbered.txt
_FNL_Lines=27

C:\GuardPost>dir %_FNL_File%
 Volume in drive E is Mount
 Volume Serial Number is 0011-AB90

 Directory of C:\GuardPost

03/19/2004 12:03 PM              1,356 test.txt.numbered.txt
              1 File(s)           1,356 bytes
              0 Dir(s)    3,090,898,944 bytes free

C:\GuardPost>%.FNL_Delete%

C:\GuardPost>dir test.txt.numbered.txt
 Volume in drive E is Mount
 Volume Serial Number is 0011-AB90

 Directory of C:\GuardPost

File Not Found

C:\GuardPost>

Related .Mount/\Commands, #Constants, $Functions, :Procedures

Resource

  Short Description
     

K

E

Y

Common Commands INTERNAL External /SWITCH Parameter Help text AddonTool
Mounted Commands .Mount/\Command CmdShorthand #Constant $FUNCTION :Procedure !GuardNote
Operating Systems NT/2K/XP/K3 NT Only NT/2K 2K Only 2K/XP XP Only XP/K3 K3 Only 2K/XP/K3

Procedures   File_Number_Lines | Parse_Command_Line_Switches | System_Info

/\
//\\
//
The\
/Sy
stem\
////
Guard
\
COME ON UP WITH US!
and
Congratulations On Your Decision
to
RISE ABOVE
THE REST!

^
/
!\
/LIB\

TheSystemGuard.com [Revised: 2007-03-29]
Copyright © 1995-2007, JWC
Computer Communications,
All Rights Reserved, Worldwide.
 Disclaimer       Privacy       About Us       More


Communication Is Business!

We Master It With Knowledge!

^
/
.\
/M^C\