; 6月以来为许多坛友提供了一些科社的图书,以下脚本是在多次上传过程中逐步完善的
; 可方便应助者分卷上传。
; 应助临近尾声,希望这个小工具能帮助更多的人
;直接另存为 自动分卷压缩.au3,运行即可
#include <File.au3>
#include <Array.au3>
$iniFile=@ScriptDir & "自动分卷压缩.ini"
$vNum=IniRead($iniFile, "Config", "vNum", "95m") ; lanzou <100m
$myExt=IniRead($iniFile, "Config", "FileExt", "*.pdf") ;默认支持pdf
$rarDirect=Number(IniRead($iniFile, "Config", "RarDirect", 105))
$path=@ScriptDir
$a=_FileListToArrayRec($path & "\", $myExt, 1, 0, 0, 0)
If Not @Error Then
For $i=1 to $a[0]
$size=FileGetSize($a[$i])
If $size>100*1048576 And $size<=$rarDirect*1048576 Then ;直接rar压缩。 不一定准确,可以根据情况调整
$controls="-s -m1 -ep"
CompressWithCmd($a[$i], 'rar', $path,$controls, 1)
ElseIf $size>$rarDirect*1048576 Then ;分卷
$controls="-s -m0 -ep -afzip -v" & $vNum
CompressWithCmd($a[$i], 'zip', $path,$controls, 1)
ENdif
Next
EndIf
$a=_FileListToArrayRec($path & "\", "*.z*|*.zip", 1, 0, 0, 0)
If Not @error Then
For $i=1 to $a[0]
$controls='-s -m1 -ep -afzip'
CompressWithCmd($a[$i], 'zip', $path, $controls, 0)
Next
EndIf
Msgbox(8192, "Info", "Done!", 2)
Func CompressWithCmd($file, $poststr, $path, $control, $flag=1)
$WinRarSoft=IniRead($iniFile, "Config", "WinRar", "C:\Program Files\WinRAR\winrar.exe") ; lanzou <100m
$DeleteSource=Number(IniRead($iniFile, "Config", "DeleteSource", 0)) ;是否删除已压缩的源文件
If $flag==1 Then
$file2=StringReplace($file, ".pdf", "")
$newfile=$path & "\" & $file2 & "." & $poststr
$mycmd='"' & $WinRarSoft & '"' & ' a "' & $newfile & '" ' & $control & ' "' & $path & '\' & $a[$i] & '"'
ConsoleWrite($mycmd & @LF)
RunWait($mycmd , $path, @SW_HIDE)
If $DeleteSource=0 Then
FileDelete($path & "\" & $file) ;不需要保留选此
Else
If Not FileExists(@ScriptDir & "\本地保留") Then DirCreate( @ScriptDir & "\本地保留")
FileMove($file, @ScriptDir & "\本地保留" , 1 ) ;需要保留的话
EndIf
Else ; z01压缩
$file2=StringReplace($file, ".z", "-")
$newfile=$path & "\" & $file2 & "." & $poststr
$mycmd='"' & $WinRarSoft & '"' & ' a "' & $newfile & '" ' & $control & ' "' & $path & '\' & $a[$i] & '"'
RunWait($mycmd , $path, @SW_HIDE)
FileDelete($path & "\" & $file)
EndIf
EndFunc
以下压缩包内包括原始脚本与编辑后小程序
https://wwm.lanzout.com/iGsja06f45ri
运行效果。