China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-07-01 22:51
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Write a file that combines multiple REG files into one View 3,197 Replies 12
Original Poster Posted 2006-09-29 19:24 ·  中国 重庆 合川区 电信
初级用户
Credits 126
Posts 38
Joined 2006-09-26 20:39
19-year member
UID 63726
Status Offline
For example, there are ten REG files, namely 1.reg to 10.reg. How to append the contents of 2-9 to 1.reg?
Floor 2 Posted 2006-09-29 20:15 ·  中国 江苏 苏州 电信
银牌会员
★★★
Credits 1,181
Posts 533
Joined 2006-08-14 12:54
19-year member
UID 60484
Status Offline
Can this work?
Floor 3 Posted 2006-09-29 21:34 ·  中国 北京 联通
银牌会员
★★★
努力做坏人
Credits 1,185
Posts 438
Joined 2006-08-28 12:00
19-year member
UID 61449
From 北京
Status Offline
I don't quite understand what the original poster means? Is it merging the contents from 2.reg to 9.reg among the 10 REG files? Or merging the contents from lines 2 to 9 of each file into one? The problem statement is not clear!!!
我今后在论坛的目标就是做个超级坏人!!!
Floor 4 Posted 2006-09-29 21:36 ·  中国 广西 贵港 电信
高级用户
★★
学无尽止
Credits 635
Posts 244
Joined 2006-04-15 05:07
20-year member
UID 53857
Gender Male
From 广西贵港
Status Offline
Floor 5 Posted 2006-09-29 21:39 ·  中国 广西 贵港 电信
高级用户
★★
学无尽止
Credits 635
Posts 244
Joined 2006-04-15 05:07
20-year member
UID 53857
Gender Male
From 广西贵港
Status Offline
This is also okay:
@echo off
regedit /s 路径\1.reg
regedit /s 路径\2.reg
regedit /s 路径\3.reg
**************
Floor 6 Posted 2006-09-29 22:05 ·  中国 重庆 合川区 电信
初级用户
Credits 126
Posts 38
Joined 2006-09-26 20:39
19-year member
UID 63726
Status Offline
Originally posted by NaturalJ0 at 2006-9-29 20:15:
Can this work? copy 1.reg+2.reg+3.reg+......+10.reg 0.reg

This is okay, but after merging, it's in this format and can't be directly imported into the registry:
Windows Registry Editor Version 5.00


"KureeBak"="dsafs"
@="mplayerc.3gp"

Windows Registry Editor Version 5.00


@="WinRAR"

There are two file headers.
You can find ^P in Word and replace it with nothing.

Then is there a way to directly remove the file headers?
Floor 7 Posted 2006-09-29 22:26 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
Try:
>Tmp.reg echo Windows Registry Editor Version 5.00
>>Tmp.reg echo.
for /f "delims=" %%i in ('dir/b *.reg') do (
for /f "skip=1 delims=" %%n in (%%i) do if not "%%i"=="Tmp.reg" >>Tmp.reg echo %%n)
Floor 8 Posted 2006-09-29 23:57 ·  中国 湖南 娄底 新化县 电信
银牌会员
★★★
Credits 1,218
Posts 485
Joined 2006-07-21 21:24
19-year member
UID 58987
From 湖南.娄底
Status Offline
The copy +..+ is good~~~!

@echo off
copy /b /y 1.txt+2.txt+3.txt+4.txt+5.txt+6.txt+7.txt+8.txt+9.txt+10.txt temp.txt
for /l %%i in (1,1,10) do del %%i.txt
ren temp.txt 1.txt
pause


But it seems there is a better way...

@@echo off
for /l %%i in (2,1,10) do type %%i.txt>>1.txt
for /l %%i in (2,1,10) do del %%i.txt
pause
Floor 9 Posted 2006-09-30 01:01 ·  中国 广东 佛山 广东睿江科技有限公司
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
The common solution is: In the for statement, use mor +1 to skip the first line of the 2 ~ 10.reg files, and then echo the content of the remaining lines to the back of the content of the 1.reg file. The code is as follows:

@echo off
echo.>>1.reg
for /l %%i in (2,1,10) do (
echo.>>1.reg
for /f "tokens=*" %%j in ('more +1 %%i.reg') do (
>>1.reg echo %%j
)
)
start notepad 1.reg
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 10 Posted 2006-09-30 01:17 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
Correct your 7th floor, just put the reg file in the same directory

@echo off
>Tmp.reg echo Windows Registry Editor Version 5.00
for /f "delims=" %%i in ('dir/on/b *.reg') do (
>>Tmp.reg echo.
for /f "skip=1 delims=" %%n in (%%i) do if not "%%i"=="Tmp.reg" >>Tmp.reg echo %%n
)
Floor 11 Posted 2006-09-30 02:03 ·  中国 重庆 合川区 电信
初级用户
Credits 126
Posts 38
Joined 2006-09-26 20:39
19-year member
UID 63726
Status Offline
Originally posted by namejm at 2006-9-30 01:01:
The common approach is: in the for statement, use mor +1 to skip the first line of the 2~10.reg files, and then echo the remaining lines to the back of the content of the 1.reg file. The code is as follows:

@echo off
echo.> ...

Really a master!
Floor 12 Posted 2006-09-30 02:12 ·  中国 湖南 娄底 新化县 电信
银牌会员
★★★
Credits 1,218
Posts 485
Joined 2006-07-21 21:24
19-year member
UID 58987
From 湖南.娄底
Status Offline
Brother namejm's method of removing the first line and then redirecting is very good...

Windows Registry Editor Version 5.00
And the repeated occurrence of this line in 1.reg will not affect the import.

[ Last edited by pengfei on 2006-9-30 at 02:18 ]
Floor 13 Posted 2006-09-30 13:01 ·  中国 湖北 荆门 电信
荣誉版主
★★★
Credits 2,013
Posts 718
Joined 2006-02-18 07:07
20-year member
UID 50550
Status Offline
```
@echo off
set filter=Windows Registry Editor Version 5.00
if "%1" == "" (set file=*.reg) else (set file=%*)

(echo %filter%) >xxx.txt
(type %file% | findstr /ixvc:"%filter%") >>xxx.txt

del %file%
ren xxx.txt xxx.reg

```
1. If no reg file to merge is specified in the parameter, it defaults to merging all reg files in the current directory.
2. The code is not tested.
Forum Jump: