怎样用批处理截取TXT文档指定位置的字符,并生成新的TXT文档
文件名为ding,里面内容如下,新的TXT文件名为sun,Memory:2048MBRAMAvailableOSMemory:1892MBRAM要求:1.截取第一行数据M...
文件名为 ding,里面内容如下,新的TXT文件名为 sun,
Memory: 2048MB RAM
Available OS Memory: 1892MB RAM
要求:
1. 截取第一行数据 Memory: 2048MB RAM,前面的空格不要
2.如果想要截取第二行数据Memory: 1892MB RAM,应该怎么做
谢谢! 展开
Memory: 2048MB RAM
Available OS Memory: 1892MB RAM
要求:
1. 截取第一行数据 Memory: 2048MB RAM,前面的空格不要
2.如果想要截取第二行数据Memory: 1892MB RAM,应该怎么做
谢谢! 展开
2个回答
展开全部
test.bat 文件内容:
@echo off
setlocal enabledelayedexpansion
set line=0
for /f "tokens=1,2* delims=:" %%i in (ding.txt) do (
set /a line+=1
echo Memory:%%j > !line!.txt
)
------------------------
下面是在命令行下的测试:
C:\Documents and Settings\seesea\桌面\test>type test.bat
@echo off
setlocal enabledelayedexpansion
set line=0
for /f "tokens=1,2* delims=:" %%i in (ding.txt) do (
set /a line+=1
echo Memory:%%j > !line!.txt
)
C:\Documents and Settings\seesea\桌面\test>test.bat
C:\Documents and Settings\seesea\桌面\test>type ding.txt
Memory: 2048MB RAM
Available OS Memory: 1892MB RAM
C:\Documents and Settings\seesea\桌面\test>type 1.txt
Memory: 2048MB RAM
C:\Documents and Settings\seesea\桌面\test>type 2.txt
Memory: 1892MB RAM
------------------------
@echo off
setlocal enabledelayedexpansion
set line=0
for /f "tokens=1,2* delims=:" %%i in (ding.txt) do (
set /a line+=1
echo Memory:%%j > !line!.txt
)
------------------------
下面是在命令行下的测试:
C:\Documents and Settings\seesea\桌面\test>type test.bat
@echo off
setlocal enabledelayedexpansion
set line=0
for /f "tokens=1,2* delims=:" %%i in (ding.txt) do (
set /a line+=1
echo Memory:%%j > !line!.txt
)
C:\Documents and Settings\seesea\桌面\test>test.bat
C:\Documents and Settings\seesea\桌面\test>type ding.txt
Memory: 2048MB RAM
Available OS Memory: 1892MB RAM
C:\Documents and Settings\seesea\桌面\test>type 1.txt
Memory: 2048MB RAM
C:\Documents and Settings\seesea\桌面\test>type 2.txt
Memory: 1892MB RAM
------------------------
博思aippt
2024-07-20 广告
2024-07-20 广告
作为深圳市博思云创科技有限公司的工作人员,对于Word文档生成PPT的操作,我们有以下建议:1. 使用另存为功能:在Word中编辑完文档后,点击文件->另存为,选择PowerPoint演示文稿(*.pptx)格式,即可将文档内容转换为PPT...
点击进入详情页
本回答由博思aippt提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询