中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-12 09:07
47,811 topics / 349,897 posts / today 0 new / 48,256 members
DOS批处理 & 脚本技术(批处理室) » [Help] How to write a batch script for automatically backing up QQ chat records?
Printable Version  2,193 / 6
Floor1 wjgyz740526 Posted 2010-05-18 19:57
中级用户 Posts 44 Credits 203
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
Floor2 Hanyeguxing Posted 2010-05-18 23:14
银牌会员 Posts 897 Credits 1,039 From 在地狱中仰望天堂
What version of QQ?
Floor3 wjgyz740526 Posted 2010-05-19 08:42
中级用户 Posts 44 Credits 203
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
Floor4 Hanyeguxing Posted 2010-05-19 12:14
银牌会员 Posts 897 Credits 1,039 From 在地狱中仰望天堂
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 ]
Floor5 wjgyz740526 Posted 2010-05-20 08:51
中级用户 Posts 44 Credits 203
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
Floor6 Hanyeguxing Posted 2010-05-20 13:54
银牌会员 Posts 897 Credits 1,039 From 在地狱中仰望天堂
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.
Floor7 wjgyz740526 Posted 2010-05-20 16:28
中级用户 Posts 44 Credits 203
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!
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023