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-06-24 11:27
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Restore a sentence of code copied from QQ View 2,820 Replies 15
Original Poster Posted 2007-03-10 09:44 ·  中国 广东 电信
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
I often discuss batch processing in the group. Some codes are directly posted, and when I copy them and save to a file, I find that all the content is squeezed into one line, and the carriage return places are occupied by annoying black blocks. There are as many black blocks as there are carriage returns. To test the code, I generally have to break lines manually, which is very troublesome. Do we just have to endure such torture?

Today in the group, someone asked me how to use batch processing to solve this problem. During the testing process, I accidentally discovered a very useful statement and share it with you:

@echo off
more test.txt>test.cmd

Usage method: Save this code as a batch file that is not test.cmd, save the code copied from QQ in the test.txt file, run the above code, and then open test.cmd to see what? Hehe, is the code restored?

By extension, as long as it is content copied from QQ, this code can be used to restore it.

Don't ask me what the principle is, because I don't know either ^_^, but there is an article worth referring to. Please see: How to extract content on different lines
Recent Ratings for This Post ( 2 in total) Click for details
RaterScoreTime
jmz573515 +8 2007-03-10 10:42
huzixuan +2 2007-03-10 20:19
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 2 Posted 2007-03-10 09:48 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
Just open it with UE. Or save it as an RTF file and copy it... Then when you open it with TXT, it's gone.
Floor 3 Posted 2007-03-10 09:56 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
Open the TXT file with Notepad and save it once, and that's it.
Floor 4 Posted 2007-03-10 10:42 ·  中国 辽宁 本溪 联通
银牌会员
★★★
Credits 1,212
Posts 464
Joined 2006-12-13 21:11
19-year member
UID 73417
Gender Male
Status Offline
Nice stuff, bump it up!
Solves quite a few practical problems...
Floor 5 Posted 2007-03-10 10:59 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
Because the carriage return in Windows is 0x0D0A, while in QQ only 0x0D is used. more will automatically recognize the encoding and carriage return.

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 6 Posted 2007-03-10 11:00 ·  中国 辽宁 本溪 联通
银牌会员
★★★
Credits 1,212
Posts 464
Joined 2006-12-13 21:11
19-year member
UID 73417
Gender Male
Status Offline
I want to ask electronixtar, how to represent 0x0D in QQ in VBS?
Floor 7 Posted 2007-03-10 11:04 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 8 Posted 2007-03-10 11:04 ·  中国 河北 保定 联通
银牌会员
★★★
Credits 1,513
Posts 554
Joined 2005-12-30 00:50
20-year member
UID 48180
Gender Male
Status Offline
Usually, carriage return and line feed are used together.
If you can see black blocks, it means there is only a carriage return character and no line feed character.
In fact, as long as you replace the 'carriage return character' with 'carriage return + line feed', it will be okay.
Save the following code as a vbs file, and drag the file onto this vbs file, and the generated new file will have no black blocks.
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Args = WScript.Arguments
Set ReadFile = FSO.OpenTextFile(Args(0), 1)
Str=ReadFile.ReadAll
ReadFile.Close
Str=Replace(Str,chr(13),chr(13)&chr(10))
Set NewFile = FSO.CreateTextFile(FSO.BuildPath(FSO.GetParentFolderName(Args(0)),"newfile.txt"), True)
NewFile.Write Str
NewFile.Close
Set FSO = Nothing
The newfile.txt in the code is the name of the new file you want to generate!
Floor 9 Posted 2007-03-10 11:09 ·  中国 河北 保定 联通
银牌会员
★★★
Credits 1,513
Posts 554
Joined 2005-12-30 00:50
20-year member
UID 48180
Gender Male
Status Offline
Hehe, my internet speed here is too slow. It took a long time to refresh. Brother electronixtar has already explained, learned it ^_^

[ Last edited by baomaboy on 2007-3-10 at 11:11 AM ]
Floor 10 Posted 2007-03-10 11:09 ·  中国 辽宁 本溪 联通
银牌会员
★★★
Credits 1,212
Posts 464
Joined 2006-12-13 21:11
19-year member
UID 73417
Gender Male
Status Offline
Why can't replace("内容",chr(13),vbcrlf) work?
Floor 11 Posted 2007-03-10 11:14 ·  中国 辽宁 本溪 联通
银牌会员
★★★
Credits 1,212
Posts 464
Joined 2006-12-13 21:11
19-year member
UID 73417
Gender Male
Status Offline
What I tried on the 8th floor, but it still doesn't work....
Floor 12 Posted 2007-03-10 12:17 ·  中国 福建 厦门 电信
初级用户
Credits 97
Posts 45
Joined 2007-01-31 06:02
19-year member
UID 78190
Gender Male
Status Offline
The carriage return encoding of the UNIX system is different from that of WINDOWS
Floor 13 Posted 2007-03-10 12:20 ·  中国 福建 厦门 电信
初级用户
Credits 97
Posts 45
Joined 2007-01-31 06:02
19-year member
UID 78190
Gender Male
Status Offline
Then, may I ask, I have a folder of text files, how to batch convert them to Windows format?
Floor 14 Posted 2007-03-10 22:22 ·  中国 吉林 四平 联通
高级用户
★★★
Credits 859
Posts 413
Joined 2006-08-14 21:55
19-year member
UID 60532
Status Offline
Nice
Floor 15 Posted 2007-03-11 00:05 ·  中国 广西 柳州 电信
初级用户
Credits 111
Posts 3
Joined 2005-04-14 00:00
21-year member
UID 38192
Gender Male
Status Offline
Use replacement is also okay.. Switch back to carriage return OK
Forum Jump: