『第 2 楼』:
使用 LLM 解释/回答一下
是一个批处理增强工具,可利用论坛搜索功能搜索其他相关帖子这是他的帮助文件:------------------------------------------------------------------------
LMOD Filter Utility Ver 1.3 (c) 2002 Horst Schaeffer
------------------------------------------------------------------------"LMOD" stands for "line modification" or "list modification". LMOD is a DOS filter (STDIN/STDOUT). If you are not familiar with
DOS input/output redirection, pls. read FILTER.TXT.LMOD extracts data from an input source (STDIN): from redirected DOS
screen output, for example, or from any file. The extracted information
is inserted into a given text or command string, and sent to STDOUT
for redirection into a file.What to insert is specified by tokens in square brackets: You may
extract a complete line, part of it (starting column, size) or a word
(by number), even several items from a source line in any order. And
this will be done either for a single line, or for a given range of
lines of the input source.What you can do with LMOD: * set environmental variables with information from (DOS) screen
output, like DIR, DATE..
* get keyboard input
* generate a command using extracted input data
* generate a list of commands for each item of a given (file) list
* extract (and modify) range of lines from a file
* modify lists or tables, arrange columnsA simple example: CD | LMOD cd > %temp%\return.bat The CD command output (the current directory path) is piped to LMOD,
which generates a new CD command where the square brackets are
replaced with the piped string. The new command is sent to a batch
file for later use.To assign extracted data to an environmental variable, redirect a SET
command (or SETX / WINSET) to a temporary batch file, and CALL it.
This method will work under all DOS versions, including Windows NT and
2000, which do not allow the manipulation of the COMMAND environment to
set variables (as done by tools like NSET).Example: CD | LMOD set currdir= > %temp%\temp.bat
call %temp%\temp.batNote:
If there is no input by pipe or redirection, the input is read from
the keyboard.
If there is no output redirection, the output will show on the
screen (handy for testing).Special LMOD features: * change case for extracted data
* use tabs (to specified column) for formatted output
* right aligned output fields (e.g. for numeric strings)
* insert CR+LF to produce several output lines for each input line
* omit CR+LF at end of the output line, to append to same line later
* insert line number (to generate file names, for example)
* insert characters by ASCII code or in quote marks
Syntax
------
LMOD options string_with_tokens
LMOD /? (shows help screen)Options are used to specify the line(s) to select, or the separators
for "words" (details see below). The string begins with the first non
blank character succeeding the options (i.e. blank spaces ignored).Tokens are expressions in square brackets.
Token expressions for input extraction
--------------------------------------
General format:
---------------
p,l field to cut out by position and length
$n word reference by number (see below)
U|L case conversion
Rs right alignment All specifications are optional. An empty token refers to
the full input line. Blank spaces are ignored in expression.
p,l FIELD: starting column p (1...), length l, separated by comma. Example: extracts field starting at column 14, length=8 Defaults:
If no length is specified, the rest of the line is taken.
Example: extracts rest of line starting position 14. If no position is given either, the complete input line is taken.
Example: CD | LMOD The current directory is "" Note: Leading spaces are preserved. Trailing spaces are always
removed from the inserted field.
$n WORD: number n (preceded by a $-sign), default number: 1. This will extract the 1st, 2nd, 3rd.. word from the input line.
Example: extracts the 6th word. If a field is also specified, the extraction is limited to this
field.
Example: takes the 2nd word from the part of the line
starting column 14. You may specify either a field or a word (number) or both. For separators and special quote handling see section below.
Word numbers are accepted in the range of 1 to 99 (two digits).
An exclamation mark refers to the last word. In addition to the word number an offset (plus/minus) may be
specified, e.g. $!-1 (one before the last word), or $%var%+2
A negative or zero reference will be corrected to $1. Note: leading and trailing spaces, as well as delimiters, are
always removed when "words" are extracted.$n:m Range: word n thru m, e.g. $2:4 or $!-3:! (last 4 words).
If the second reference (m) is before the first one (n), it will
be ignored. One blank space is inserted between words. Note: is the same as:
U|L CASE: upper|lower case conversion Example: echo %string% | LMOD set string= > temp.bat Conversion includes extended ASCII characters of the standard
DOS character set (cp 437).
See CASE103.PAT for country specific modifications.
Rs ALIGNMENT: for right aligned string in output field of size n.
(The size defaults to the source field size, if specified.)
This will (re)produce formatted output of numeric strings
in right aligned columns. Example: < list.txt LMOD ........ Note: the alignment only works if the input field is NOT larger
than the size given by the Rs parameter.
Special output tokens
---------------------
Tab to position n (1...) in the output line, inserting blank
spaces up to the specified column.
This token has no effect, if the output has already passed the
specified position. Insert CR+LF (more than one output line may be generated for
each input line). Omit CR+LF at the end of the output. Should be placed at the
end of the output string, because the rest will be ignored. Insert line number
Three digits are used by default, starting 001 for the first
output line. (Actually, the output units will be numbered:
a unit may be broken into several physical lines by tokens.) The starting value can be preset by option /N. Example: /N00007
This will also define the number of digits used (max 9 allowed). insert character with ASCII code n (decimal) insert character(s) that may conflict with the DOS command line
handling, unless enclosed in quote marks. Example: or
. The quote marks will be removed.In case you need the "
> %temp%\temp.bat ... will take line 6 of the DIR output with the (first) file
listed, and extract the date tag at column 29. dir *.* /b | LMOD /L* ren "" ""> %temp%\temp.bat ... will rename all files to lower case (LFN's assumed)Empty lines:Usually it makes no sense to produce any output for empty lines, so
LMOD doesn't by default. Note however, that LMOD first locates the
physical lines as specified (empty lines do count!). Only empty lines
within the given range are dropped.When a single line is specified, LMOD will give you the first non-empty
line starting at the given line number. Note that the default is /L1,
i.e. without the /L option the first non-empty line is taken./E Option to deactivate the special handling of empty lines
Extracting words
----------------
Words are separated by blank space. In addition the following separators
are defined by default (same as for batch file parameters): comma, semicolon, equal signCustom separators by option:/S.... This option deactivates the standard separators except blank
space. Instead, the following symbols (if any), up to a blank
space, are taken as new separators. If you need any of the
standard separators, you must specify them again.
Example: LMOD /S,# ..output string../B... Same as /S, but the blank space separator is also deactivatedSeparators are always stripped from the input before words are inserted
into the output line.Note that a word does not have to consist of letters. Anything, numbers
or symbols as well, may be "words" if enclosed in separators. Watch the
comma in numeric strings!
Quote handling
--------------
Quoted strings (only "double" quote marks) in an input line are regarded
as ONE word, though they may include blank spaces and other separators.
The quote marks will be stripped. Note that this special quote handling
is only applied, when words are extracted.Example:
assumed input: ONE "TWO THREE" FOUR
produces: TWO THREE
"" makes: "TWO THREE" (quote marks restored)
will be: FOURIn case you do not want the special quote handling, define the quote
mark as additional separator (option /S or /B). It is recommended to
specify two quote marks, especially when there are more occurrences of
quote marks in the command line. You should always have balanced pairs
of quote marks to avoid misinterpretation by COMMAND.COM.Example: LMOD /S,"" Output "" > file.2
TAB's in input file
-------------------
If there are TAB codes (Ctrl+I) in the input file, they will be expanded
to the appropriate number of blank spaces before any action. Take this
into account for field extraction (position, size) as well as for
separator handling.
Leading and trailing spaces
---------------------------
When words are extracted, all leading and trailing blank spaces are
removed. For fields (position, length) or when the complete line is
taken, only trailing spaces are removed; leading spaces remain!Any blank spaces within the output string (as given in the command line)
are preserved. In addition you may use the TAB token to insert spaces
up to a given column, or the right alignment of output fields.Important:
Trailing spaces at the end of the output are also removed. This will
avoid accidental spaces in an environmental variable when you produce a
SET command.Examples: echo set X=A > temp.bat (result: "A "<img src="images/smilies/face-wink.png" align="absmiddle" border="0">
echo set X=A> temp.bat (result: "A"<img src="images/smilies/face-wink.png" align="absmiddle" border="0">
echo A | LMOD set X= > temp.bat (result: "A"<img src="images/smilies/face-wink.png" align="absmiddle" border="0">Only when you produce an output without CR/LF, the spaces before the
token will remain.Example: echo A | LMOD set X= > temp.bat (result: "A "<img src="images/smilies/face-wink.png" align="absmiddle" border="0">
Notes
-----
The file size is not limited. Maximum line size (in/out): 2Kb,
Errorlevel 0: ok, 1: invalid token/expression, 2: invalid options
Remember to delete temporary files.
Examples (assuming WIN9x/english, LFN's)
----------------------------------------(1) Set environmental variable to volume label of drive A: VOL A: | LMOD set LABEL= > %temp%\temp.bat
call %temp%\temp.bat(2) Make batch file to restore current drive and directory later
(generating 2 output lines): CD | LMOD cd "" > %temp%\POPDIR.BAT(3) Keyboard input LMOD /E set INPUT= > %temp%\temp.bat
call %temp%\temp.bat Note: if you want to allow an empty input string, you must use
option /E. Otherwise LMOD ignores empty lines, and the input will
have to be terminated by Ctrl+"Z" in this case.(4) CHDIR to the directory of a given file with unknown path (%fn%),
using DIR header information in line 4: dir "%fn%" | LMOD /L4 cd "" > %temp%\temp.bat (To be honest, there is an easier way: CD "%fn%\.."<img src="images/smilies/face-wink.png" align="absmiddle" border="0">(5) Day of week and date to a log file: echo.| DATE | LMOD Updated: , >> some.log(6) Date and time into a single line: echo.| DATE | LMOD Updated: , >> some.log
echo.| TIME | LMOD at >> some.log(7) Get (short) extension of file %fname% (which may include path): dir "%fname%" | LMOD /L6 set EXT=> %temp%\temp.bat
call %temp%\temp.bat With the same method you can extract the (short) filename without
extension, or the size, date/time tag, LFN..(8) Rename a file (name may include path) to lower case: dir %fname% /b | LMOD ren "%fname%" "" > %temp%\temp.bat
call %temp%\temp.bat Note that DIR /b lists filenames without path, unless option /s
is used in addition.(9) Rename all files in %folder% to lower case: dir "%folder%" /b/a-d| LMOD /L* ren "%folder%\" ""> %temp%\temp.bat
call %temp%\temp.bat
Syntax summary (see: LMOD /?)
-----------------------------
LMOD options string_with_tokensOptions:
/Ln line to select (default: first non blank line)
/L* all lines
/E include empty input lines (default: no output)
/S.. delimiters for word extraction, instead of default (,;=)
/B.. as /S, but excluding blank space as delimiter
/Nn starting number (for token ), default: /N001Insert from source line (expression in square brackets):
default : complete line
p,l from position p, length l (default rest of line)
$n word number n (! for last word), optional offset
$n:m for range n thru m
U|L convert to upper|lower case
Rn right aligned in output field of size nOther tokens:
insert CR+LF
omit CR+LF at end of output
line number (digits acc. to option, default:3)
tab to position n in output line
ASCII code n (decimal)
quoted char/string (e.g. for redirection symbols)----
LMOD is freeware by Horst Schaeffer - no warranties of any kind
Contact - E-Mail: horst.schaeffer@gmx.net= 04 DEC 2002
是一个批处理增强工具,可利用论坛搜索功能搜索其他相关帖子这是他的帮助文件:------------------------------------------------------------------------
LMOD 过滤器实用程序 版本 1.3 (c) 2002 Horst Schaeffer
------------------------------------------------------------------------"LMOD"代表“行修改”或“列表修改”。LMOD 是一个 DOS 过滤器(标准输入/标准输出)。如果您不熟悉 DOS 输入/输出重定向,请阅读 FILTER.TXT。LMOD 从输入源(标准输入)中提取数据:例如从重定向的 DOS 屏幕输出中,或从任何文件中。提取的信息被插入到给定的文本或命令字符串中,并发送到标准输出以便重定向到文件中。要插入的内容由方括号中的标记指定:您可以提取完整的行、行的一部分(起始列、大小)或一个单词(按编号),甚至可以按任何顺序从源行中提取多个项目。并且这可以针对单行或输入源的给定行范围进行。您可以用 LMOD 做什么: * 用(DOS)屏幕输出中的信息设置环境变量,如 DIR、DATE 等 * 获取键盘输入 * 使用提取的输入数据生成命令 * 为给定(文件)列表的每个项目生成命令列表 * 从文件中提取(并修改)行范围 * 修改列表或表格,排列列一个简单的例子: CD | LMOD cd > %temp%\return.bat CD 命令的输出(当前目录路径)通过管道传递给 LMOD,LMOD 生成一个新的 CD 命令,其中方括号被传递的字符串替换。新命令被发送到批处理文件以便以后使用。要将提取的数据分配给环境变量,将 SET 命令(或 SETX / WINSET)重定向到临时批处理文件,然后调用它。这种方法在所有 DOS 版本下都有效,包括 Windows NT 和 2000,这些版本不允许像 NSET 这样的工具那样操作 COMMAND 环境来设置变量。例子: CD | LMOD set currdir= > %temp%\temp.bat
call %temp%\temp.bat注意: 如果没有通过管道或重定向输入,则从键盘读取输入。 如果没有输出重定向,则输出将显示在屏幕上(便于测试)。特殊 LMOD 功能: * 更改提取数据的大小写 * 使用制表符(到指定列)进行格式化输出 * 右对齐输出字段(例如用于数字字符串) * 插入 CR+LF 为每个输入行生成多个输出行 * 省略输出行末尾的 CR+LF,以便稍后附加到同一行 * 插入行号(例如生成文件名) * 按 ASCII 码或在引号中插入字符语法
------
LMOD 选项 带标记的字符串
LMOD /? (显示帮助屏幕)选项用于指定要选择的行,或用于“单词”的分隔符(详细信息见下文)。字符串以选项后面的第一个非空白字符开头(即忽略空格)。标记是方括号中的表达式。输入提取的标记表达式
--------------------------------------
一般格式:
---------------
p,l 通过位置和长度剪切的字段
$n 按编号引用的单词(见下文)
U|L 大小写转换
Rs 右对齐 所有规范都是可选的。空标记 指完整的输入行。表达式中的空格被忽略。
p,l 字段:起始列 p(1...),长度 l,用逗号分隔。例如: 提取从列 14 开始、长度为 8 的字段 默认值:
如果未指定长度,则取行的其余部分。
例如: 提取从位置 14 开始的行的其余部分。如果也未指定位置,则取完整的输入行。
例如:CD | LMOD 当前目录是 "" 注意:保留前导空格。插入的字段的结尾空格始终被移除。
$n 单词:编号 n(前面有 $ 符号),默认编号:1。这将提取输入行中的第 1、2、3... 个单词。
例如: 提取第 6 个单词。如果还指定了字段,则提取限制在该字段内。
例如: 从行中从列 14 开始的部分提取第 2 个单词。您可以指定字段或单词(编号)或两者。有关分隔符和特殊引号处理,请参见下文部分。
单词编号接受 1 到 99 的范围(两位数字)。
感叹号 指最后一个单词。除了单词编号外,还可以指定偏移量(加/减),例如 $!-1(最后一个单词之前的一个),或 $%var%+2
负或零引用将被纠正为 $1。注意:提取“单词”时,始终移除前导和尾随空格以及分隔符。$n:m 范围:单词 n 到 m,例如 $2:4 或 $!-3:!(最后 4 个单词)。
如果第二个引用(m)在第一个引用(n)之前,则会被忽略。单词之间插入一个空格。注意: 与: 相同
U|L 大小写:大写|小写转换 例如:echo %string% | LMOD set string= > temp.bat 转换包括标准 DOS 字符集(cp 437)的扩展 ASCII 字符。
有关国家特定修改,请参见 CASE103.PAT。
Rs 对齐:在大小为 n 的输出字段中右对齐字符串。
(如果指定,大小默认为源字段大小。)
这将(重新)生成右对齐列中的数字字符串的格式化输出。例如:< list.txt LMOD ........ 注意:仅当输入字段不大于 Rs 参数给出的大小时,对齐才有效。
特殊输出标记
---------------------
在输出行中定位到位置 n(1...),插入空格直到指定列。
如果输出已经超过指定位置,此标记无效。 插入 CR+LF(每个输入行可能生成多个输出行)。 省略输出末尾的 CR+LF。应放在输出字符串的末尾,因为其余部分将被忽略。 插入行号 默认使用三位数字,第一个输出行从 001 开始。(实际上,输出单元将被编号:一个单元可能通过 标记分解为多个物理行。)起始值可以通过选项 /N 设置。例如:/N00007
这也将定义使用的位数(最多允许 9 位)。 插入 ASCII 码为 n(十进制)的字符 插入可能与 DOS 命令行处理冲突的字符(除非用引号括起来)。例如: 或 。引号将被移除。如果您需要将 "
> %temp%\temp.bat ... 将获取 DIR 输出中列出的第一个文件的第 6 行,并提取列 29 处的日期标记。 dir *.* /b | LMOD /L* ren "" "" > %temp%\temp.bat ... 将所有文件重命名为小写(假设为长文件名)空行:通常为空行生成任何输出没有意义,所以 LMOD 默认不这样做。然而请注意,LMOD 首先定位指定的物理行(空行也计数!)。仅给定范围内的空行被删除。当指定单行时,LMOD 将给您从给定行号开始的第一个非空行。注意默认是 /L1,即没有 /L 选项时取第一个非空行。/E 选项以取消对空行的特殊处理
提取单词
----------------
单词由空格分隔。此外,默认定义以下分隔符(与批处理文件参数相同):逗号、分号、等号通过选项自定义分隔符:/S.... 此选项取消标准分隔符,仅保留空格。相反,以下符号(如果有的话)直到空格被视为新的分隔符。如果您需要任何标准分隔符,必须重新指定它们。
例如:LMOD /S,# ..输出字符串../B... 与 /S 相同,但也取消空格分隔符分隔符在插入输出行之前总是从输入中剥离。请注意,单词不必由字母组成。任何内容、数字或符号,如果被分隔符包围,也可能是“单词”。注意数字字符串中的逗号!
引号处理
--------------
输入行中的带引号字符串(仅“双”引号)被视为一个单词,尽管它们可能包含空格和其他分隔符。引号将被剥离。请注意,这种特殊引号处理仅在提取单词时应用。例子:
假设输入: ONE "TWO THREE" FOUR
生成: TWO THREE
"" 生成: "TWO THREE"(恢复引号)
将是: FOUR如果您不希望特殊引号处理,将引号定义为附加分隔符(选项 /S 或 /B)。建议指定两个引号,特别是当命令行中有更多引号出现时。您应该始终有平衡的引号对以避免被 COMMAND.COM 误解。例子: LMOD /S,"" Output "" > file.2
输入文件中的制表符
-------------------
如果输入文件中有制表符代码(Ctrl+I),它们将在任何操作之前扩展为适当数量的空格。在字段提取(位置、大小)和分隔符处理时也要考虑这一点。
前导和尾随空格
---------------------------
提取单词时,所有前导和尾随空格都被移除。对于字段(位置、长度)或取完整行时,仅移除尾随空格;前导空格保留!输出字符串中(如命令行中给定的)的任何空格都保留。此外,您可以使用 TAB 标记插入空格直到给定列,或输出字段的右对齐。重要:输出末尾的尾随空格也被移除。这将避免在生成 SET 命令时环境变量中出现意外空格。例子: echo set X=A > temp.bat (结果:"A ")
echo set X=A> temp.bat (结果:"A")
echo A | LMOD set X= > temp.bat (结果:"A")仅当您生成没有 CR/LF 的输出时, 标记之前的空格才会保留。例子: echo A | LMOD set X= > temp.bat (结果:"A ")
注意事项
-----
文件大小不受限制。最大行大小(输入/输出):2Kb,错误级别 0:正常,1:无效标记/表达式,2:无效选项记得删除临时文件。
例子(假设 WIN9x/英语,长文件名)
----------------------------------------(1) 设置环境变量为驱动器 A 的卷标: VOL A: | LMOD set LABEL= > %temp%\temp.bat
call %temp%\temp.bat(2) 制作批处理文件以便稍后恢复当前驱动器和目录(生成 2 个输出行): CD | LMOD cd "" > %temp%\POPDIR.BAT(3) 键盘输入 LMOD /E set INPUT= > %temp%\temp.bat
call %temp%\temp.bat 注意:如果您希望允许空输入字符串,必须使用选项 /E。否则 LMOD 忽略空行,在这种情况下输入必须用 Ctrl+"Z" 终止。(4) 使用第 4 行的 DIR 标题信息将 CHDIR 到给定文件的目录 (%fn%): dir "%fn%" | LMOD /L4 cd "" > %temp%\temp.bat (老实说,有更简单的方法:CD "%fn%\..")(5) 星期几和日期到日志文件: echo.| DATE | LMOD Updated: , >> some.log(6) 日期和时间到单行: echo.| DATE | LMOD Updated: , >> some.log
echo.| TIME | LMOD at >> some.log(7) 获取文件 %fname% 的(短)扩展名(可能包含路径): dir "%fname%" | LMOD /L6 set EXT= > %temp%\temp.bat
call %temp%\temp.bat 用同样的方法可以提取不带扩展名的(短)文件名、大小、日期/时间标记、长文件名等。(8) 将文件(名称可能包含路径)重命名为小写: dir %fname% /b | LMOD ren "%fname%" "" > %temp%\temp.bat
call %temp%\temp.bat 注意 DIR /b 列出没有路径的文件名,除非另外使用 /s 选项。(9) 将 %folder% 中的所有文件重命名为小写: dir "%folder%" /b/a-d| LMOD /L* ren "%folder%\" "" > %temp%\temp.bat
call %temp%\temp.bat
语法总结(见:LMOD /?)
-----------------------------
LMOD 选项 带标记的字符串选项:
/Ln 选择行 (默认:第一个非空白行)
/L* 所有行
/E 包含空输入行(默认:无输出)
/S.. 单词提取的分隔符,代替默认(,;=)
/B.. 与 /S 相同,但排除空格作为分隔符
/Nn 起始编号(用于标记 ),默认:/N001从源行插入(方括号中的表达式):
默认 :完整行
p,l 从位置 p,长度 l(默认其余部分)
$n 单词编号 n(! 表示最后一个单词),可选偏移量
$n:m 范围 n 到 m
U|L 转换为大写|小写
Rn 在大小为 n 的输出字段中右对齐其他标记:
插入 CR+LF
省略输出末尾的 CR+LF
行号(位数根据选项,默认:3)
在输出行中定位到位置 n
ASCII 码 n(十进制)
带引号的字符/字符串(例如用于重定向符号)----
LMOD 是 Horst Schaeffer 的免费软件 - 无任何保证
联系 - 电子邮件:horst.schaeffer@gmx.net= 2002 年 12 月 4 日
|