Jump to content

Search the Community

Showing results for tags '7-Zip'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • Forum FAQ
  • AutoIt

Calendars

  • Community Calendar

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 4 results

  1. I updated the UDF by Patric Pendelin to use the MemoryDLL UDF. There are only two new functions: _SevenZip_Load & _SevenZip_Free The first function must be called before using any other functions included in the UDF and the other should be called to free memory when the UDF is no longer needed! The size of binary from the module was excessive so I used the ZLMA UDF to compress it. It will be decompressed at run time before its loaded into memory. The only advantage of using this UDF is that it removes the need to included any DLLs in your script. A lot of functions haven't been added yet! For those that dare: The API for the 7-Zip32.dll module is included in the attachment. These functions work in the same way you would you use the standalone 7za.exe executable so the Help.chm file applies to these functions aswell. Thats it, Enjoy! The code below is a sneak peak at the actually UDF, meaning it dosen't work without the other includes and the embed binary. - Download the attachment. #include-once #include "MemoryDLL.au3" #include "LZMA.au3" Global $__7ZIPDLL = Default, $__7ZIPINIT = False #cs =============================================================================== Name: 7-Zip.au3 Version: 1.0 Datum: 08.07.2008 Author: Patric Pendelin eMail: <patric.pendelin (a) gmx.de> Modified By: Decipher Script Function: _SevenZip_Load() _SevenZip_Extract($s_Archive, $s_Out="", $s_Pass="", $szCmdLine="", $s_Overwrite="", $hwnd=0, $szOutput="NULL", $dwSize=0) Extracts files from an archive _SevenZip_Add($s_Archive, $s_Out = "", $s_Typ = "7z32", $i_Comp = 5, $s_Pass = "", $szCmdLine = "", $hwnd = 0, $szOutput = "NULL", $dwSize = 0) Add files to an archive _SevenZip_GetVersion() Get 7_zip32.dll Version _SevenZip_GetRunning() _SevenZip_CheckArchive($s_Archive, $i_iMode = 0) _SevenZip_GetArchiveType($s_Archive) _SevenZip_GetFileCount($s_Archive) _SevenZip_GetUDFVersion() Returns UDF version number _SevenZip_Free() #ce =============================================================================== Func _SevenZip_Load() If Not $__7ZIPINIT Then $__7ZIPDLL = MemoryDllOpen(__7ZIPBIN()) $__7ZIPINIT = True EndIf EndFunc Func _SevenZip_Free() If $__7ZIPINIT Then MemoryDllClose($__7ZIPDLL) $__7ZIPINIT = False $__7ZIPDLL = Default EndIf EndFunc ;=============================================================================== ; Function Name: _SevenZip_Extract ; Description: Extracts files from an archive ; ; Parameter(s): $s_Archive: Fullpath to Archive-File ; $s_Out: Specifies a destination directory where files are to be extracted. (Def. "") ; $s_Pass: Specifies password. (Def. "") ; $szCmdLine: Command Line Commands. (Def. "") ; $s_Overwrite: Specifies the overwrite mode during extraction, to overwrite files already present on disk. (Def. "") ; -1: Overwrite All existing files without prompt. ; -2: Skip extracting of existing files. ; -3: aUto rename extracting file (for example, name.txt will be renamed to name_1.txt). ; -4: auto rename existing file (for example, name.txt will be renamed to name_1.txt). ; $hwnd: The window handle of the application which calls 7-zip32.dll. (Def. 0) ; $szOutput: The buffer because 7-zip32.dll returns the result. (Def. "NULL") ; $dwSize: Größe des Puffers. When the result exceeds designated size, it is economized in this size. ; If size is 1 or more, always NULL letter is added lastly. (Def. 0) ; ; Syntax: _SevenZip_Extract($s_Archive, $s_Out="", $s_Pass="", $szCmdLine="", $s_Overwrite="", $hwnd=0, $szOutput="NULL", $dwSize=0) ; Return Value(s): On Success -Return 1 ; On Failure -@error ; Author(s): Patric Pendelin <patric.pendelin (a) gmx.de> ;=============================================================================== Func _SevenZip_Extract($s_Archive, $s_Out = "", $s_Pass = "", $szCmdLine = "", $s_Overwrite = "", $hwnd = 0, $szOutput = "NULL", $dwSize = 0) ; Set Output directory If $s_Out = "" Then Local $as_Res = StringSplit($s_Archive, "\") For $i = 1 To $as_Res[0] - 1 $s_Out &= $as_Res[$i] & "\" Next EndIf ; (Overwrite mode) switch: If $s_Overwrite = 1 Then $s_Overwrite = "-aoa"; Overwrite All existing files without prompt. ElseIf $s_Overwrite = 2 Then $s_Overwrite = "-aos"; Skip extracting of existing files. ElseIf $s_Overwrite = 3 Then $s_Overwrite = "-aou"; Auto rename extracting file (for example, name.txt will be renamed to name_1.txt). ElseIf $s_Overwrite = 4 Then $s_Overwrite = "-aot"; Auto rename existing file (for example, name.txt will be renamed to name_1.txt). EndIf If $szCmdLine = "" Then $szCmdLine = ' x "' & $s_Archive & '" ' & $s_Overwrite & ' -o"' & $s_Out & '" -p"' & $s_Pass & '"' Local $aRet = MemoryDllCall($__7ZIPDLL, "int", "SevenZip", "hwnd", $hwnd, "str", $szCmdLine, "str", $szOutput, "int", $dwSize) Return SetError(@error, "", $aRet[0]) EndFunc ;==> _SevenZip_Extract ;=============================================================================== ; Function Name: _SevenZip_Add ; Description: Extracts files from an archive ; ; Parameter(s): $s_Archive: Fullpath to Archive-File ; $s_Out: Specifies a destination directory where files are to be extracted. (Def. "") ; $s_Typ: Specifies the type of archive. ; $i_Comp: Sets level of compression. [0 | 1 | 3 | 5 | 7 | 9 ] ; $s_Pass: Specifies password. (Def. "") ; $szCmdLine: Command Line Commands. (Def. "") ; $hwnd: The window handle of the application which calls 7-zip32.dll. (Def. 0) ; $szOutput: The buffer because 7-zip32.dll returns the result. (Def. "NULL") ; $dwSize: Größe des Puffers. When the result exceeds designated size, it is economized in this size. ; If size is 1 or more, always NULL letter is added lastly. (Def. 0) ; ; Syntax: _SevenZip_Add($s_Archive, $s_Out = "", $s_Typ = "7z32", $i_Comp = 5, $s_Pass = "", $szCmdLine = "", $hwnd = 0, $szOutput = "NULL", $dwSize = 0) ; Return Value(s): On Success -Return 1 ; On Failure -@error ; Author(s): Patric Pendelin <patric.pendelin (a) gmx.de> ;=============================================================================== Func _SevenZip_Add($s_Archive, $s_Out = "", $s_Typ = "7z32", $i_Comp = 5, $s_Pass = "", $szCmdLine = "", $hwnd = 0, $szOutput = "NULL", $dwSize = 0) If $szCmdLine = "" Then If $s_Pass = "" Then $szCmdLine = '-t' & $s_Typ & ' a "' & $s_Archive & '" "' & $s_Out & '" -mx=' & $i_Comp Else $szCmdLine = '-t' & $s_Typ & ' a "' & $s_Archive & '" "' & $s_Out & '" -p"' & $s_Pass & '" -mhe=on -mx=' & $i_Comp EndIf EndIf Local $aRet = MemoryDllCall($__7ZIPDLL, "int", "SevenZip", "hwnd", $hwnd, "str", $szCmdLine, "str", $szOutput, "int", $dwSize) Return SetError(@error, "", $aRet[0]) EndFunc ;==> _SevenZip_Add ;=============================================================================== ; Function Name: _SevenZip_GetVersion ; Description: The version of 7-zip32.dll is returned. ; ; Parameter(s): None. ; ; Syntax: _SevenZip_GetVersion() ; Return Value(s): On Success -Return File Version ; On Failure -@error ; Author(s): Patric Pendelin <patric.pendelin (a) gmx.de> ;=============================================================================== Func _SevenZip_GetVersion() Local $aRet = MemoryDllCall($__7ZIPDLL, "int", "SevenZipGetVersion") Return SetError(@error, "", $aRet[0]) EndFunc ;==> _SevenZip_GetVersion ;=============================================================================== ; Function Name: _SevenZip_GetRunning ; Description: Whether or not presently 7-zip32.dll while operating, you obtain. ; Application side before executing API which by all means accompanies file access such as compressing/thawing, ; it is necessary to check whether because of this feasibility. ; ; Parameter(s): None. ; ; Syntax: _SevenZip_GetRunning() ; Return Value(s): On Success -Return 1(It is in the midst of executing.) ; Return 0(Is not in the midst of executing, (feasibility).) ; On Failure -@error ; Author(s): Patric Pendelin <patric.pendelin (a) gmx.de> ;=============================================================================== Func _SevenZip_GetRunning() Local $aRet = MemoryDllCall($__7ZIPDLL, "int", "SevenZipGetRunning") Return SetError(@error, "", $aRet[0]) EndFunc ;==> _SevenZip_GetRunning ;=============================================================================== ; Function Name: _SevenZip_CheckArchive ; Description: Whether or not presently 7-zip32.dll while operating, you obtain. ; As the archive file which the designated file supports ; It returns whether or not it is correct. ; ; Parameter(s): $s_Archive: Fullpath to Archive file ; ; Syntax: _SevenZip_CheckArchive($s_Archive) ; Return Value(s): On Success -Return 1 (At the time of correct archive file.) ; Return 0 (When the file is illegitimate.) ; On Failure -@error ; Author(s): Patric Pendelin <patric.pendelin (a) gmx.de> ;=============================================================================== Func _SevenZip_CheckArchive($s_Archive, $i_iMode = 0) Local $aRet = MemoryDllCall($__7ZIPDLL, "int", "SevenZipCheckArchive", "str", $s_Archive, "int", $i_iMode) Return SetError(@error, "", $aRet[0]) EndFunc ;==> _SevenZip_CheckArchive ;=============================================================================== ; Function Name: _SevenZip_GetArchiveType ; Description: Type of the archive file ; ; Parameter(s): $s_Archive: Fullpath to Archive file ; ; Syntax: _SevenZip_GetArchiveType($s_Archive) ; Return Value(s): On Success -Return 1 (ZIP type) ; Return 2 (7z32 type) ; On Failure -@error ; Author(s): Patric Pendelin <patric.pendelin (a) gmx.de> ;=============================================================================== Func _SevenZip_GetArchiveType($s_Archive) Local $aRet = MemoryDllCall($__7ZIPDLL, "int", "SevenZipGetArchiveType", "str", $s_Archive) Return SetError(@error, "", $aRet[0]) EndFunc ;==> _SevenZip_GetArchiveType ;=============================================================================== ; Function Name: _SevenZip_GetFileCount ; Description: Type of the archive file ; ; Parameter(s): $s_Archive: The number of files in the Archive file. ; ; Syntax: _SevenZip_GetFileCount($s_Archive) ; Return Value(s): On Success -Return Numer of files ; On Failure -@error 1: Can´t opens a DLL file for use in MemoryDllCall. ; @error 2: Error in MemoryDllCall ; ; Author(s): Patric Pendelin <patric.pendelin (a) gmx.de> ;=============================================================================== Func _SevenZip_GetFileCount($s_Archive) Local $aRet = MemoryDllCall($__7ZIPDLL, "int", "SevenZipGetFileCount", "str", $s_Archive) Return SetError(@error, "", $aRet[0]) EndFunc ;==> _SevenZip_GetFileCount #region ### BINARY ### Func __7ZIPBIN() #cs Name: 7-ZIP32 BINARY Version 9.20.00.02 Requirements: Windows9x/Me/NT/200x/XP/Vista/7 Author: Akita Minoru ( Http://Akky.Xrea.Jp/support.Html ) Download the Library: 7-Zip-Library.7z Basic Usage: #include "7-Zip.au3" _SevenZip_Load() Dim $sCommandLine = "Accepts Switches and etc" _SevenZip_Exec($sCommandLine) ; See the included 7-Zip.chm documentation _SevenZip_Free() Exit
  2. change linked image paths in excel 2007 Open XML Files with AutoIt and 7-zip: #include <File.au3> #include <WinAPIFiles.au3> ;Required 7-zip Global $Path7z = @ProgramFilesDir & "\7-Zip" If Not FileExists($Path7z & "\7z.exe") Then MsgBox(16, "", "7z.exe not found in path " & $Path7z) Exit EndIf Global $bFileOpen Global $sFileRead ;Global $sOldImg = "C:\Users\MyUserName\Documents\MyImageFolder" ;Global $sNewImg = "C:\Users\ANOTHERUSERNAME\Documents\AnotherImageFolder" Global $sOldImg = "C:\Users\MyUserName\Documents\MyImageFolder\My%20Image1.png" Global $sNewImg = "C:\Users\ANOTHERUSERNAME\Documents\AnotherImageFolder\My%20Image1.png" Global $sFileSelectFolder = FileSelectFolder("Directory to change excel image paths", "") Global $sTempDir = @ScriptDir & "\TempDir" Global $sFileCoreXml = $sTempDir & "\docProps\core.xml" If FileExists($sTempDir) Then DirRemove($sTempDir, $DIR_REMOVE) ;Look for excel files in selected directory and subdirectories Global $aFileList = _FileListToArrayRec($sFileSelectFolder, "*.xls*", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) If Not @error Then For $i = 1 To $aFileList[0] ;Discard some kind of temp files (locked files from antivirus?) If StringLeft($aFileList[$i], 1) = "~" Then ContinueLoop $bFileOpen = _WinAPI_FileInUse($aFileList[$i]) If $bFileOpen = 0 Then ;use x command to keep the folder stucture, -aoa Overwrite All existing files without prompt, use -r to unzip the subfolders from the zip file RunWait('"' & $Path7z & '\7z.exe" x -aoa -r -y "' & $aFileList[$i] & '" -o"' & $sTempDir & '"', $Path7z, @SW_HIDE) If FileExists($sFileCoreXml) Then $sFileRead = FileRead($sFileCoreXml) If __ReplaceImagePaths($sTempDir, $sOldImg, $sNewImg) = 1 Then Consolewrite("--> Image path replaced in file: " & $aFileList[$i] & @CRLF) EndIf ;Help File 7-zip.chm 'Switch can be used in any place in command line' RunWait('"' & $Path7z & '\7z.exe" a -r -tzip -y "' & $aFileList[$i] & '" "' & $sTempDir & '\*"', $Path7z, @SW_HIDE) Else If FileExists($sTempDir & "\EncryptedPackage") Then Consolewrite("Error password protected file: " & $aFileList[$i] & @CRLF) EndIf DirRemove($sTempDir, $DIR_REMOVE) Else Consolewrite("Error Locked file: " & $aFileList[$i] & @CRLF) EndIf Next Else MsgBox(16, "Error", "No excel files were found in the folder") EndIf Func __ReplaceImagePaths($sTempDir, $sFind, $sReplace) ;List all files with .xml.rels extension in the directory \xl\drawings\_rels Local $aFileListDrw = _FileListToArray($sTempDir & "\xl\drawings\_rels", "*.xml.rels", 1, True) If @error = 1 Then ;MsgBox (0, "", "Path was invalid") SplashTextOn("Title", "Path was invalid", -1, -1, -1, -1, 1, "", 24) Sleep(2000) SplashOff() Exit EndIf If @error = 4 Then ;MsgBox (0, "No files", "No files were found") SplashTextOn("Title", "No files were found", -1, -1, -1, -1, 1, "", 24) Sleep(2000) SplashOff() Exit EndIf Local $iRetval ;Loop through the array For $i = 1 To $aFileListDrw[0] $iRetval = _ReplaceStringInFile($aFileListDrw[$i], $sFind, $sReplace) Next If Not $iRetval = -1 Then Return 1 EndFunc Some references: https://stackoverflow.com/questions/37145369/change-path-to-picture-links-in-excel http://www.jkp-ads.com/Articles/Excel2007FileFormat.asp EDITED: Note: it seems that if User Account Control (UAC) is enabled then 7zip is unable to overwrite the destination file (using the same name). In this case, a possible solution would be to rename the original excel file before (see _PathSplit in help file). In my case i prefer just to disable UAC
  3. There is an Example called _7ZIPExtractEx_Example_using_Callback.AU3 in the 7-Zip UDF. I found a problem. If one file in the 7z archive is too big,the progress bar will stop for a long time. How can I get the exact progress even though there are big files in the archive? In other words,how to get the exact extracted file size without delay ? 7Zip_UDF.zip
  4. Hello all I was wondering if any one new of a way to extract the files from a Comic Book Archive (.cbr)? My original thought was to use 7za.exe (&-zip console app) but when I run: 7za x 1.cbr 7-zip returns: Processing archive: 1.cbr Error: Can not open file as archive Does anyone a suggestion or other method? PS I am trying to make a .cbr to .pdf script
×
×
  • Create New...