多文件最后添加内容?
多个文件夹:
1001\1001.vmx
1002\1002.vmx
...
1400\1400.vmx
...
2001\2001.vmx
2002\2002.vmx
...
2400\2400.vmx
...
想要在本文件夹及子文件夹中后缀为vmx的文件的最后,添加下面二行内容:
numvcpus = "4"
cpuid.coresPerSocket = "4"
想要实现效果:
ethernet0.address = "00:50:56:07:00:02"
numvcpus = "4"
cpuid.coresPerSocket = "4"
使用下面代码:- @echo off
- setlocal enabledelayedexpansion
- for /f "delims=" %%a in ('dir /a-d /b /s *.vmx') do (
- pushd "%%~dpa"
- (for /f "delims=" %%b in ('type "%%a"') do (
- for %%i in (*.vmx) do echo "numvcpus = "4"" >>%%i
- for %%i in (*.vmx) do echo "cpuid.coresPerSocket = "4"" >>%%i
- ))
- )
复制代码 结果:重复添加了97次,变成
ethernet0.address = "00:50:56:07:00:02"
numvcpus = "4"
cpuid.coresPerSocket = "4"
numvcpus = "4"
cpuid.coresPerSocket = "4"
numvcpus = "4"
cpuid.coresPerSocket = "4"
numvcpus = "4"
cpuid.coresPerSocket = "4"
numvcpus = "4"
cpuid.coresPerSocket = "4"
.... |