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
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



