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-08-12 09:54
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] How to write a batch script for automatically backing up QQ chat records? View 2,195 Replies 6
Original Poster Posted 2010-05-18 19:57 ·  中国 江苏 扬州 电信
中级用户
Credits 203
Posts 44
Joined 2003-08-14 00:00
22-year member
UID 8600
Gender Male
Status Offline
Want to write a batch script for automatically backing up QQ chat records. I found a ready - made one in the forum: http://www.cn-dos.net/forum/viewthread.php?tid=30934&fpage=1&highlight=qq%2B%E5%A4%87%E4%BB%BD
It's very good, but there are defects: 1. It uses wmic to get the local hard disk list. I'm afraid 2k and xp don't support it. It's better to use a specified drive letter; 2. Now the QQ user data is in the users directory, which is not in the same directory as QQ.exe. I have modified it, and the code is as follows:

+++++++++++++++++++++++++++++++++++++++++++++++++++
@echo off
echo.
@echo The system is locating the path of your QQ, please wait...
echo.
for /r %%a in (c d e f g h i j k l m n o p q r s t u v w x y z ) do (
for /r "delims=" %%b in ('dir /s /b /a-d %%a:\QQ.exe 2^>NUL') do (if exist "%%b" set QQpath=%%~dpb&goto qq_path)
)
exit
:qq_path
echo Location completed, the path of your QQ is: %QQpath%
dir "%QQPath%" /ad /b /w|findstr "^*$">%temp%\qqlist.txt
cd /d "%QQPath%"&&cd..&&dir .\users /ad /b /w|findstr "^*$">>%temp%\qqlist.txt
@echo All QQ numbers on this computer are as follows:
@echo ------------------
type %temp%\qqlist.txt
@echo ------------------
for /f "tokens=*" %%i in (%temp%\list.txt) do set pp=%%i&call :copy

:copy
xcopy /s /c /h /q /r /y ".\%pp%" "D:\QQ资料备份\%pp%"

++++++++++++++++++++++++++++++++++++++++++++++++++++++

But it didn't succeed. Please ask:
1. How to use variables to represent the parent directory of a certain directory?
2. What's wrong with the above code??

Thank you
Floor 2 Posted 2010-05-18 23:14 ·  中国 吉林 延边朝鲜族自治州 延吉市 电信
银牌会员
★★★
正在学习中的菜鸟...
Credits 1,039
Posts 897
Joined 2009-03-01 15:34
17-year member
UID 140302
Gender Male
From 在地狱中仰望天堂
Status Offline
Floor 3 Posted 2010-05-19 08:42 ·  中国 江苏 扬州 电信
中级用户
Credits 203
Posts 44
Joined 2003-08-14 00:00
22-year member
UID 8600
Gender Male
Status Offline
The problem is here. If it's 2007, 2008, then the QQ user and qq.exe are in the same directory, while in 2009, 2010 they are not in the same directory, so I need to know how to use variables to represent the parent directory of a certain directory?

I'm looking for both situations like this:

dir "%QQPath%" /ad /b /w|findstr "^[0-9]*$">%temp%\qqlist.txt
cd /d "%QQPath%"&&cd..&&dir .\users /ad /b /w|findstr "^[0-9]*$">>%temp%\qqlist.txt

But it didn't work
Floor 4 Posted 2010-05-19 12:14 ·  中国 吉林 延边朝鲜族自治州 延吉市 电信
银牌会员
★★★
正在学习中的菜鸟...
Credits 1,039
Posts 897
Joined 2009-03-01 15:34
17-year member
UID 140302
Gender Male
From 在地狱中仰望天堂
Status Offline
1. Find whether the end of the line is bin\QQ.exe to determine if it is QQ2009
2. If %r% is the main program path of 2009QQ, then its USER directory is %r:~0,-10%Users

[ Last edited by Hanyeguxing on 2010-5-19 at 12:16 ]
Floor 5 Posted 2010-05-20 08:51 ·  中国 江苏 扬州 电信
中级用户
Credits 203
Posts 44
Joined 2003-08-14 00:00
22-year member
UID 8600
Gender Male
Status Offline
Originally posted by Hanyeguxing at 2010-5-19 12:14 PM:
If %r% is the main program path of 2009QQ, then its USER directory is %r:~0,-10%Users

[ Last edited by Hanyeguxing on 2010-5-19 at 12:16 ]


How did you come up with this? You assume it's installed in a specific directory. What if it's a custom directory? So %r:~0,-10% might be error-prone
Floor 6 Posted 2010-05-20 13:54 ·  中国 吉林 延边朝鲜族自治州 延吉市 电信
银牌会员
★★★
正在学习中的菜鸟...
Credits 1,039
Posts 897
Joined 2009-03-01 15:34
17-year member
UID 140302
Gender Male
From 在地狱中仰望天堂
Status Offline
Originally posted by wjgyz740526 at 2010-5-20 08:51:


How did you get this?? Do you think it's installed in a specific directory? What if it's a custom directory??? So %r:~0,-10% this might go wrong

The original poster really worries me. Taking the installation directory as D:\Program Files\QQ2009 as an example, QQ is in D:\Program Files\QQ2009\Bin directory, and the records are in D:\Program Files\QQ2009\Users. Bin and Users are subdirectories of the installation directory.
If %r% is the main program path of 2009QQ, then its USER directory is %r:~0,-10%Users. That is to say, if D:\Program Files\QQ2009\Bin\QQ.exe, then D:\Program Files\QQ2009\Users is the record directory.
Floor 7 Posted 2010-05-20 16:28 ·  中国 江苏 扬州 电信
中级用户
Credits 203
Posts 44
Joined 2003-08-14 00:00
22-year member
UID 8600
Gender Male
Status Offline
Just now I carefully read the set help again and finally understood it—before I never used it like this. Thanks to the brother upstairs!

Actually, I successfully used my own clumsy method yesterday, but I thought it was really clumsy so I asked the question.

Thanks!
Forum Jump: