标题: [文本处理] [分享]批处理如果指定第a行,删除第m个到第n个字符? [打印本页]
作者: Batcher 时间: 2019-6-16 13:46 标题: [分享]批处理如果指定第a行,删除第m个到第n个字符?
如果指定第a行,删除第m个到第n个字符,这要怎么实现?- @echo on&setlocal enabledelayedexpansion
- set n=0
- for /f "usebackq delims=" %%b in ("a.txt") do (
- set /a n+=1
- if !n! equ 1 (
- set "var=%%b"
- echo %var%
- echo !var:%var:~36,12%=!>>ok.txt
- ) else (
- echo %%b>>ok.txt
- )
- )
-
- pause
复制代码
我自己这样写的,好像有问题
作者: Batcher 时间: 2019-6-16 13:47
- @echo off
- setlocal enabledelayedexpansion
- set n=0
- (for /f "delims=" %%b in ('type "a.txt"') do (
- set /a n+=1
- if !n! equ 1 (
- set "var=%%b"
- echo,!var:~0,35!!var:~48!
- ) else (
- echo,%%b
- )
- ))>"ok.txt"
复制代码
作者: Batcher 时间: 2019-6-16 13:57
- @echo off
- setlocal enabledelayedexpansion
- set n=0
- (for /f "delims=" %%b in ('type "a.txt"') do (
- set /a n+=1
- if !n! equ 1 (
- set "x=%%b"
- set "var=%%b"
- call echo %%var:!x:~36,12!=%%
- ) else (
- echo,%%b
- )
- ))>"ok.txt"
复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |