史萊姆論壇

史萊姆論壇 (http://forum.slime.com.tw/)
-   網路軟硬體架設技術文件 (http://forum.slime.com.tw/f133.html)
-   -   管理下載電影目錄的指令碼 (http://forum.slime.com.tw/thread133236.html)

psac 2004-11-13 01:12 PM

管理下載電影目錄的指令碼
 
經常在1台不關機的電腦上下載電影,一次性通常下載很多,等都下載完畢後開始解壓縮文件,感覺很麻煩,儘管使用 TotalCmd 工具,所以編寫了下面的指令碼,使用 JPSoft 的 4NT 執行。

它會遍歷下載目錄下面的所有子目錄,然後解壓縮其中的 RAR 文件,如果一切正常,則移除源文件,如果電影是多張 CD 的,則會自動解壓縮 CD 子目錄下的 RAR 文件。全部工作由日誌可以查詢。


程式碼:
: Movies donwload direcotry manager helper
: Created by Che Ming 2004

setlocal
alias rar="c:\program files\WinRAR\rar.exe"
set rootdir=%_CWD
set logfilename=%rootdir%\mop.log
set filetoprocess=__filetoprocess.$$$

for /a:d /h %subdir in (*.*) do (
pushd "%rootdir%\%subdir"
gosub WriteLog "Starting in [%subdir%] ..."
iff %@files["CD?",d] GE 1 then
for %i in (1 2 3 4 5) do (
iff exist "CD%i%" then
pushd "%rootdir%\%subdir%\CD%i%"
gosub WriteLog "Starting in [%subdir%\CD%i%] ..."
gosub ExtractArchives
popd
endiff
)
else
gosub ExtractArchives
endiff
popd
)
endlocal

quit

:WriteLog [msg]
iff exist %logfilename% then
echo %_DATE %_TIME : %msg% >> %logfilename%
else
echo %_DATE %_TIME : %msg% > %logfilename%
endiff
return 0

:ExtractArchives
set files_to_operation=%@FILES[*.R??]
gosub WriteLog "Files to Operaion: %files_to_operation%"
iff %files_to_operation% GE 1 then
if exist __filetoprocess.$$$ then *del "%filetoprocess%" /q/y
*dir /b *.r?? > "%filetoprocess%"
rar t *.rar
iff %? NE 0 then
gosub WriteLog "Find error when testing archives..."
else
rar x *.rar
iff %? NE 0 then
gosub WriteLog "Find errors when extracting archives..."
else
for %filename in (@"%filetoprocess%") *del /q/y %filename
endiff
endiff
*del /q/y "%filetoprocess%"
else
gosub WriteLog "Files number is not enough!"
endiff
return


所有時間均為台北時間。現在的時間是 11:00 PM

Powered by vBulletin® 版本 3.6.8
版權所有 ©2000 - 2024, Jelsoft Enterprises Ltd.

『服務條款』

* 有問題不知道該怎麼解決嗎?請聯絡本站的系統管理員 *


SEO by vBSEO 3.6.1