如何在Windows命令提示符中添加大量注释?

2024-05-15 17:57:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我有很多文字,我想补充作为评论。例如,我想把CHKDSK的enitre help部分:

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.

有没有一种方法可以大量使用注释代码(比如Python中的""" comment here, can be multiple lines""")你知道吗


Tags: andofthetoonlysizescanif
1条回答
网友
1楼 · 发布于 2024-05-15 17:57:10

如果使用Vim,这很容易做到:

  1. 移到要注释的第一行的第一列。你知道吗
  2. <C-v>Ctrl+V)进入块选择模式。你知道吗
  3. 将所选内容移动到要注释的最后一行的第一列。你知道吗
  4. 键入Irem<esc>(插入,键入rem,返回正常模式)。你知道吗

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

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

CHKDSK /? | python3 comment.py

相关问题 更多 >