如何将大量评论添加到 Windows 命令提示符中?

How do I add mass comments into Windows Command prompt?

我有很多文字要添加为评论。例如,我想把 CHKDSK 的 entre 帮助部分:

Checks a disk and displays a status report.


CHKDSK [volume[[path]filename]]] [/F] [/V] [/R] [/X] [/I] [/C] [/L[:size]] [/B] [/scan] [/spotfix]


  volume              Specifies the drive letter (followed by a colon),
                      mount point, or volume name.
  filename            FAT/FAT32 only: Specifies the files to check for
                      fragmentation.
  /F                  Fixes errors on the disk.
  /V                  On FAT/FAT32: Displays the full path and name of every
                      file on the disk.
                      On NTFS: Displays cleanup messages if any.
  /R                  Locates bad sectors and recovers readable information
                      (implies /F, when /scan not specified).
  /L:size             NTFS only:  Changes the log file size to the specified
                      number of kilobytes.  If size is not specified, displays
                      current size.
  /X                  Forces the volume to dismount first if necessary.
                      All opened handles to the volume would then be invalid
                      (implies /F).
  /I                  NTFS only: Performs a less vigorous check of index
                      entries.
  /C                  NTFS only: Skips checking of cycles within the folder
                      structure.
  /B                  NTFS only: Re-evaluates bad clusters on the volume
                      (implies /R)
  /scan               NTFS only: Runs a online scan on the volume
  /forceofflinefix    NTFS only: (Must be used with "/scan")
                      Bypass all online repair; all defects found
                      are queued for offline repair (i.e. "chkdsk /spotfix").
  /perf               NTFS only: (Must be used with "/scan")
                      Uses more system resources to complete a scan as fast as
                      possible. This may have a negative performance impact on
                      other tasks running on the system.
  /spotfix            NTFS only: Runs spot fixing on the volume
  /sdcleanup          NTFS only: Garbage collect unneeded security descriptor
                      data (implies /F).
  /offlinescanandfix  Runs an offline scan and fix on the volume.
  /freeorphanedchains FAT/FAT32/exFAT only: Frees any orphaned cluster chains
                      instead of recovering their contents.
  /markclean          FAT/FAT32/exFAT only: Marks the volume clean if no
                      corruption was detected, even if /F was not specified.

The /I or /C switch reduces the amount of time required to run Chkdsk by
skipping certain checks of the volume.

然而,必须在每一行代码的前面放置 rem 标签是非常烦人的(并且耗时),例如:

rem Checks a disk and displays a status report.


rem CHKDSK [volume[[path]filename]]] [/F] [/V] [/R] [/X] [/I] [/C] [/L[:size]] [/B] [/scan] [/spotfix]


rem   volume              Specifies the drive letter (followed by a colon),
rem                       mount point, or volume name.
rem   filename            FAT/FAT32 only: Specifies the files to check for
rem                       fragmentation.
rem   /F                  Fixes errors on the disk.
rem   /V                  On FAT/FAT32: Displays the full path and name of every
rem                       file on the disk.
rem                       On NTFS: Displays cleanup messages if any.
rem   /R                  Locates bad sectors and recovers readable information
rem                       (implies /F, when /scan not specified).
rem   /L:size             NTFS only:  Changes the log file size to the specified
rem                       number of kilobytes.  If size is not specified, displays
rem                       current size.
rem   /X                  Forces the volume to dismount first if necessary.
rem                       All opened handles to the volume would then be invalid
rem                       (implies /F).
rem   /I                  NTFS only: Performs a less vigorous check of index
rem                       entries.
rem   /C                  NTFS only: Skips checking of cycles within the folder
rem                       structure.
rem   /B                  NTFS only: Re-evaluates bad clusters on the volume
rem                       (implies /R)
rem   /scan               NTFS only: Runs a online scan on the volume
rem   /forceofflinefix    NTFS only: (Must be used with "/scan")
rem                       Bypass all online repair; all defects found
rem                       are queued for offline repair (i.e. "chkdsk /spotfix").
rem   /perf               NTFS only: (Must be used with "/scan")
rem                       Uses more system resources to complete a scan as fast as
rem                       possible. This may have a negative performance impact on
rem                       other tasks running on the system.
rem   /spotfix            NTFS only: Runs spot fixing on the volume
rem   /sdcleanup          NTFS only: Garbage collect unneeded security descriptor
rem                       data (implies /F).
rem   /offlinescanandfix  Runs an offline scan and fix on the volume.
rem   /freeorphanedchains FAT/FAT32/exFAT only: Frees any orphaned cluster chains
rem                       instead of recovering their contents.
rem   /markclean          FAT/FAT32/exFAT only: Marks the volume clean if no
rem                       corruption was detected, even if /F was not specified.

rem The /I or /C switch reduces the amount of time required to run Chkdsk by
rem skipping certain checks of the volume.

有什么方法可以批量评论代码(比如 """ comment here, can be multiple lines"""in Python?)

如果您使用 Vim:

,这很容易做到
  1. 移动到您要评论的第一行的第一列。
  2. <C-v>Ctrl+V)进入块select模式。
  3. 将 selection 移动到您要评论的最后一行的第一列。
  4. 键入Irem<esc>(插入,键入rem,返回正常模式)。

或者,由于您似乎熟悉 Python,您可以将其通过此脚本进行管道传输,然后复制输出:

import sys
for line in sys.stdin:
    sys.stdout.write("rem " + line)

CHKDSK /? | python3 comment.py