Skip to content

Commit

Permalink
0812 close #1 close #2
Browse files Browse the repository at this point in the history
現在要處理 #3
  • Loading branch information
pulipulichen committed Aug 12, 2019
1 parent 4ffc3c3 commit 1277cad
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 11 deletions.
55 changes: 44 additions & 11 deletions archive-util.au3
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,14 @@ Func addArchive()
; ----------------------------------
Local $path7z = @ScriptDir & '\7-zip\7z.exe'

; ----------------------------------
; 建立列表
Local $fileList = ""
For $i = 1 To $CmdLine[0]
If FileExists($CmdLine[$i]) Then
$fileList = $fileList & ' "' & $CmdLine[$i] & '"'
EndIf
Next
;MsgBox($MB_SYSTEMMODAL, "", $fileList)

;MsgBox($MB_SYSTEMMODAL, "", $path7z)

; ----------------------------------

Local $archiveFilename
Local $workingDir = @WorkingDir

; 如果檔案只有一個,那就以該檔案為名字
; 如果檔案有很多個,那就取上層目錄為檔案名字
Expand All @@ -50,16 +43,49 @@ Func addArchive()

; ------------------------------------

; @TODO 如果裡面只有一個資料夾,那把裡面的檔案搬出來後再來壓縮
If $CmdLine[0] = 1 Then
uniqueDir($CmdLine[1])
EndIf

; ----------------------------------
; 建立列表
Local $fileList = ""
If $CmdLine[0] = 1 And StringInStr(FileGetAttrib($CmdLine[1]), "D") Then
Local $trimLength = StringLen($CmdLine[1]) + 1
$archiveFilename = '../' & $archiveFilename


Local $subFileList = _FileListToArray($CmdLine[1])
FileChangeDir($CmdLine[1])
;MsgBox($MB_SYSTEMMODAL, "", $CmdLine[1])
For $i = 1 To $subFileList[0]
;MsgBox($MB_SYSTEMMODAL, "", $CmdLine[1])
If FileExists($subFileList[$i]) Then
Local $f = $subFileList[$i]
$fileList = $fileList & ' "' & $f & '"'
EndIf
Next
Else

For $i = 1 To $CmdLine[0]
If FileExists($CmdLine[$i]) Then
$fileList = $fileList & ' "' & $CmdLine[$i] & '"'
EndIf
Next
EndIf

; ------------------------------------

Local $cmd = $path7z & ' a -t' & $archiveFormat & ' -mx=9 ' & $archiveFilename & '.zip' & $fileList

;MsgBox($MB_SYSTEMMODAL, "", $cmd)
;Exit

RunWait($cmd)

; ------------------------------------

FileChangeDir($workingDir)
For $i = 1 To $CmdLine[0]
FileRecycle($CmdLine[$i])
Next
Expand Down Expand Up @@ -92,17 +118,21 @@ Func unarchive()
RunWait($cmd)

; ------------------------------
;FileRecycle($file)
FileRecycle($file)

; ------------------------------
uniqueDir($sFileName)

EndFunc

Func uniqueDir($sFileName)
If StringInStr(FileGetAttrib($sFileName), "D") = False Then
Return
EndIf

Local $fileList = _FileListToArray($sFileName)
If $fileList[0] = 1 And $fileList[1] = $sFileName Then
;MsgBox($MB_SYSTEMMODAL, "", $fileList[1])
MsgBox($MB_SYSTEMMODAL, "", $fileList[1])

Local $subFileList = _FileListToArray($sFileName & '/' & $sFileName)
For $i = 1 To $subFileList[0]
Expand Down Expand Up @@ -131,6 +161,9 @@ EndFunc

; ------------------------------------

;uniqueDir('testbbb')
;Exit

If $CmdLine[0] = 1 And (StringRight($CmdLine[1], 4) = '.zip' Or StringRight($CmdLine[1], 4) = '.rar' Or StringRight($CmdLine[1], 3) = '.7z') Then
unarchive()
Else
Expand Down
Binary file modified archive-util.exe
Binary file not shown.

0 comments on commit 1277cad

Please sign in to comment.