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

时间:2016-10-07 22:41:08

标签: python windows comments command-prompt

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

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.

但是,必须在每行代码的前面放置 else: try: arr = np.array(data, dtype=dtype, copy=copy) except (ValueError, TypeError) as e: exc = TypeError('DataFrame constructor called with ' 'incompatible data and dtype: %s' % e) raise_with_traceback(exc) if isinstance(arr, (np.ndarray, Series, Index)): if data.dtype.names: data_columns = list(data.dtype.names) data = dict((k, data[k]) for k in data_columns) if columns is None: columns = data_columns mgr = self._init_dict(data, index, columns, dtype=dtype) elif getattr(data, 'name', None): mgr = self._init_dict({data.name: data}, index, columns, dtype=dtype) else: mgr = self._init_ndarray(data, index, columns, dtype=dtype, copy=copy) elif arr.ndim == 0 and index is not None and columns is not None: if isinstance(data, compat.string_types) and dtype is None: dtype = np.object_ if dtype is None: dtype, data = _infer_dtype_from_scalar(data) values = np.empty((len(index), len(columns)), dtype=dtype) values.fill(data) mgr = self._init_ndarray(values, index, columns, dtype=dtype, copy=False) else: raise PandasError('DataFrame constructor not properly called!') 标记非常烦人(并且非常耗时),例如:

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中的rem?)

1 个答案:

答案 0 :(得分:0)

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

  1. 移至要评论的第一行的第一列。
  2. <C-v> Ctrl + V )进入区块选择模式。
  3. 将选择内容移动到要评论的最后一行的第一列。
  4. 键入Irem<esc>(插入,键入rem,返回正常模式)。
  5. 或者,既然你似乎熟悉Python,你可以通过这个脚本管它,然后复制输出:

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

    CHKDSK /? | python3 comment.py