Jump to content

Help with 7z command line


Recommended Posts

Hi I am trying to create a zip archive with a single file using the command line 7zip

My code is here

;Set the parameters of the create zip command
                     Local $param1 = @ScriptDir&"\7z.exe "
                     Local $param3 = "a -tzip -aoa -mx=9 "
                     Local $param4 = @TempDir&"\tmp.zip "
                     Local $param7 = " > "
                     ;Create zip
                    RunWait($param1&$param3&$param4&$sFileOpenDialog&$param7&$tmpTextfile, "", @SW_HIDE)

The problem is that this creates a zip file with the file I want, but also an empty folder (where 7zip exists) inside the zip tile.

 

Link to comment
Share on other sites

I think the correct syntax is:

"7z" and not "7z.exe" which may also explain why you get 7zip in your archive.

I am still looking though.

... also in all the examples I have the "-aoa" switch is placed after the file: ( 7z a -tzip -mx9 tmp.zip -aoa )

Edited by l3ill
Link to comment
Share on other sites

I think the correct syntax is:

"7z" and not "7z.exe" which may also explain why you get 7zip in your archive.

I am still looking though.

​No I do not think it works, at least as far as I have tested it.

Here is my whole program for you to see. Initially I used the windows zip function but this depended on the OS so I switched to the external 7zip. I have copied the command line 7z.exe into the script folder.

Apart from the problem I mentioned, it also does not create the tmp.txt file inside the temp dir, hm... weird.

; ====================================================
; ============ DataText encoder/decoder ==============
; ====================================================
; Version: 1.4
; Language:       English
; Author:         "sv3ora"
; Website:        http://www.qrp.gr/datatext
;
; ----------------------------------------------------------------------------
; Script Start
; ----------------------------------------------------------------------------

#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ColorConstants.au3>
#include <String.au3>
#include <FileConstants.au3>
#include <base32.au3>
#include <Crypt.au3>
#include <Date.au3>
#include <GuiEdit.au3>
#include <Zip.au3> ;delete this

_Main()


Func RestartScript()
      If @Compiled = 1 Then
         Run( FileGetShortName(@ScriptFullPath))
      Else
         Run( FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath))
      EndIf
   Exit
EndFunc



Func SetTime()
    Local $time = _TicksToTime(Int(TimerDiff($begin)), $hour, $min, $sec)
    ControlSetText($WinMain, "", $label, StringFormat("%02i:%02i:%02i", $hour, $min, $sec))
EndFunc



Func _Main()
    ; Creates window
    Global $WinMain = GUICreate('DataText v1.4 by sv3ora', 570, 350)

    ; Creates main edit
    Local $idEditText = GUICtrlCreateEdit('', 5, 5, 560, 280)
    _GUICtrlEdit_SetLimitText($idEditText, 6400000)

    ; Create the buttons
    Local $idEncodeButton = GUICtrlCreateButton('Encode', 5, 290, 85, 25)
    Local $idDecodeButton = GUICtrlCreateButton('Decode', 96, 290, 85, 25)
    Local $idInfoButton = GUICtrlCreateButton('?', 545, 325, 20, 20)
    ; Creates the password box with blured and centered input
    Local $idInputPass = GUICtrlCreateInput('', 187, 290, 100, 24, BitOR($ES_CENTER, $ES_PASSWORD))
    ; Pass text label
    Local $idLabel = GUICtrlCreateLabel('     Password', 191, 294, 91, 17)
    ; Set the background color of the label Password.
    GUICtrlSetBkColor($idLabel, $COLOR_WHITE)
    ; Create the combo to select the crypting algorithm
    Local $idCombo = GUICtrlCreateCombo("", 291, 290, 88, 25, $CBS_DROPDOWNLIST)
    GUICtrlSetData($idCombo, "3DES|AES (128bit)|AES (192bit)|AES (256bit)|DES|RC2|RC4", "RC4")
    ; Create the player buttons
    Local $playButton = GUICtrlCreateButton('Play', 5, 320, 40, 25)
    Local $stopButton = GUICtrlCreateButton('Stop', 50, 320, 40, 25)
    ; SLIDERS
    Local $volumeSliderLabel = GUICtrlCreateLabel("Volume:", 100, 325)
    Local $volumeSlider = GUICtrlCreateSlider(150, 320, 110, 25)
    GUICtrlSetData(-1, 50)
    ; Create the combo to select the play delay
    Local $delaySliderLabel = GUICtrlCreateLabel("Delay:", 270, 325)
    Local $idCombo2 = GUICtrlCreateCombo("", 314, 320, 65, 25, $CBS_DROPDOWNLIST)
    GUICtrlSetData($idCombo2, "None|0.25 sec|0.5 sec|1 sec|2 sec|3 sec|4 sec|5 sec", "None")
    
    Global $fileIsImage
    
    ;timer
    GUICtrlCreateLabel("Elapsed:", 387, 325)
    Global $hour, $min, $sec, $begin
    Global $label = GUICtrlCreateLabel("00:00:00", 453, 325, 78, 20)
    
    ; PROGRESS bar
    GUICtrlCreateProgress(453, 293, 78, 20)
    GUICtrlSetData(-1, 0)
    GUICtrlCreateLabel("Progress:", 387, 295)
    GUICtrlCreateLabel("0%", 535, 295)

    ; Shows window
    GUISetState()

    Local $iAlgorithm = $CALG_RC4
    Local $dEncrypted
    Local $dDecrypted
    Local $encodedDataZIP
    Local $iDelay


    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop



            Case $idCombo ; Check when the combobox is selected and retrieve the correct algorithm.
                Switch GUICtrlRead($idCombo) ; Read the combobox selection.
                    Case "3DES"
                        $iAlgorithm = $CALG_3DES

                    Case "AES (128bit)"
                        $iAlgorithm = $CALG_AES_128

                    Case "AES (192bit)"
                        $iAlgorithm = $CALG_AES_192

                    Case "AES (256bit)"
                        $iAlgorithm = $CALG_AES_256

                    Case "DES"
                        $iAlgorithm = $CALG_DES

                    Case "RC2"
                        $iAlgorithm = $CALG_RC2

                    Case "RC4"
                        $iAlgorithm = $CALG_RC4

                EndSwitch












            Case $idEncodeButton
                ; When you press Encode

;;;;;;;;;;;;;; SELECT FILE TO ENCODE ;;;;;;;;;;;;;;;;
                ; Create a constant variable in Local scope of the message to display in FileOpenDialog.
               Local $sMessage = "Select file to encode."

               ; Display an open dialog to select a file.
               Local $sFileOpenDialog = FileOpenDialog($sMessage, @ScriptDir&"\DataText_all_files", "Images (*.jpg;*.png;*.gif)|All files (*.*)", $FD_FILEMUSTEXIST + $FD_MULTISELECT)
               If @error Then
                  ; Display the error message.
                  GUICtrlSetData($idEditText, "Error. No file was selected!")
                  RestartScript()
                  ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder.
                  FileChangeDir(@ScriptDir)
               Else
                  ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder.
                  FileChangeDir(@ScriptDir)

                  ; Replace instances of "|" with @CRLF in the string returned by FileOpenDialog.
                  $sFileOpenDialog = StringReplace($sFileOpenDialog, "|", @CRLF)
               EndIf
               
               ;start timer
               $begin = TimerInit()
               AdlibRegister("SetTime", 1000)

;;;;;;;;;;;;;; COMPRESS SELECTED FILE ;;;;;;;;;;;;;;;;

               GUICtrlSetData($idEditText, "Wait for data processing. This may take a while...")

               ; PROGRESS bar
               GUICtrlCreateProgress(453, 293, 78, 20)
               GUICtrlSetData(-1, 10)
               GUICtrlCreateLabel("Progress:", 387, 295)
               GUICtrlCreateLabel("10%", 535, 295)

               ;$sFileOpenDialog2 is the tmp.zip file and its path
               Local $sFileOpenDialog2 = @TempDir&"\tmp.zip"
               Local $tmpTextfile = @TempDir&"\tmp.txt"

               ;compress the file selected
               ;First check if tmp.zip file exists
                Local $iFileExists = FileExists($sFileOpenDialog2)
                
                ; Display a message of whether the file exists or not.
                If $iFileExists Then
                   
                     ;Delete the temporary tmp.zip and tmp.txt file.
                     FileDelete($sFileOpenDialog2)
                     FileDelete($tmpTextfile)
                     ;Set the parameters of the create zip command
                     Local $param1 = @ScriptDir&"\7z.exe "
                     Local $param3 = "a -tzip -aoa -mx=9 "
                     Local $param4 = @TempDir&"\tmp.zip "
                     Local $param7 = " > "
                     ;Create zip
                    RunWait($param1&$param3&$param4&$sFileOpenDialog&$param7&$tmpTextfile, "", @SW_HIDE)
GUICtrlSetData($idEditText, $param1&$param3&$param4&$sFileOpenDialog&$param7&$tmpTextfile)
Sleep(10000)
                Else
                     ;Delete the temporary tmp.txt file.
                     FileDelete($tmpTextfile)
                    ;Set the parameters of the create zip command
                     Local $param1 = @ScriptDir&"\7z.exe "
                     Local $param3 = "a -tzip -aoa -mx=9 "
                     Local $param4 = @TempDir&"\tmp.zip "
                     Local $param7 = " > "
                     ;Create zip
                    RunWait($param1&$param3&$param4&$sFileOpenDialog&$param7&$tmpTextfile, "", @SW_HIDE)
GUICtrlSetData($idEditText, $param1&$param3&$param4&$sFileOpenDialog&$param7&$tmpTextfile)
Sleep(10000)
                 EndIf
                 

                 ; PROGRESS bar
               GUICtrlCreateProgress(453, 293, 78, 20)
               GUICtrlSetData(-1, 20)
               GUICtrlCreateLabel("Progress:", 387, 295)
               GUICtrlCreateLabel("20%", 535, 295)

;;;;;;;;;;;;;; READ COMPRESSED FILE ;;;;;;;;;;;;;;;;
                  ; Open the tmp.zip file for reading and store the handle to a variable.
                  Local $sFileOpen = FileOpen($sFileOpenDialog2, $FO_READ)
                     If $sFileOpen = -1 Then
                        GUICtrlSetData($idEditText, "An error occurred when reading the file.")
                        Return False
                     EndIf

                  ; Read the contents of the tmp.zip file using the handle returned by FileOpen.
                  Local $dataZIP = FileRead($sFileOpen)

                  ; PROGRESS bar
               GUICtrlCreateProgress(453, 293, 78, 20)
               GUICtrlSetData(-1, 40)
               GUICtrlCreateLabel("Progress:", 387, 295)
               GUICtrlCreateLabel("40%", 535, 295)

                  ;Close the temporary tmp.zip file
                  FileClose($sFileOpen)

                  ; Delete the temporary tmp.zip file.
                  FileDelete($sFileOpenDialog2)

               ; PROGRESS bar
               GUICtrlCreateProgress(453, 293, 78, 20)
               GUICtrlSetData(-1, 60)
               GUICtrlCreateLabel("Progress:", 387, 295)
               GUICtrlCreateLabel("60%", 535, 295)


               ;If the password box is empty, do not use encryption
               If GuiCtrlRead($idInputPass) = "" Then
                  ;Encode the contents of the non encrypted variable to zbase32
                  $encodedDataZIP = _Base32_Encode($dataZIP)

               ; PROGRESS bar
               GUICtrlCreateProgress(453, 293, 78, 20)
               GUICtrlSetData(-1, 80)
               GUICtrlCreateLabel("Progress:", 387, 295)
               GUICtrlCreateLabel("80%", 535, 295)

               ;If password box is not empty then use encryption
               Else
                  ; Calls the encryption.
                $dEncrypted = _Crypt_EncryptData($dataZIP, GUICtrlRead($idInputPass), $iAlgorithm) ; Encrypt the text with the new cryptographic key.

                  ;Encode the contents of the encrypted variable to zbase32
                  $encodedDataZIP = _Base32_Encode($dEncrypted)

               ; PROGRESS bar
               GUICtrlCreateProgress(453, 293, 78, 20)
               GUICtrlSetData(-1, 80)
               GUICtrlCreateLabel("Progress:", 387, 295)
               GUICtrlCreateLabel("80%", 535, 295)
               EndIf

;;;;;;;;;;;;;; DISPLAY ENCODED DATA ;;;;;;;;;;;;;;;;
                  ; Put encoded data to text box
                  GUICtrlSetData($idEditText, $encodedDataZIP)

               ; PROGRESS bar
               GUICtrlCreateProgress(453, 293, 78, 20)
               GUICtrlSetData(-1, 100)
               GUICtrlCreateLabel("Progress:", 387, 295)
               Local $p1 = GUICtrlCreateLabel("100%", 535, 295)

                  ;wait a bit
                  Sleep(1000)
                  GUICtrlDelete($p1)

               ; PROGRESS bar
               GUICtrlCreateProgress(453, 293, 78, 20)
               GUICtrlSetData(-1, 0)
               GUICtrlCreateLabel("Progress:", 387, 295)
               GUICtrlCreateLabel("0%", 535, 295)
               
               ;end timer
               AdlibUnRegister("SetTime")
               GUICtrlCreateLabel("00:00:00", 453, 325, 78, 20)
               
               
               
               
               
               
               
               
               Case $idCombo2 ; Check when the combobox is selected and retrieve the correct delay.
                Switch GUICtrlRead($idCombo2) ; Read the combobox selection.
                    Case "None"
                        $iDelay = 0

                    Case "0.25 sec"
                        $iDelay = 250

                    Case "0.5 sec"
                        $iDelay = 500

                    Case "1 sec"
                        $iDelay = 1000

                    Case "2 sec"
                        $iDelay = 2000

                    Case "3 sec"
                        $iDelay = 3000

                    Case "4 sec"
                        $iDelay = 4000
                        
                    Case "5 sec"
                        $iDelay = 5000

                EndSwitch
               
               
               
               
               
               
               
               
               
               
               
               
               Case $playButton
                ; When you press Play
               ; Disable the play and delay buttons
               GUICtrlSetState($playButton, $GUI_DISABLE)
               GUICtrlSetState($idCombo2, $GUI_DISABLE)
               ;Read text from input box
               Local $readedText = GUICtrlRead($idEditText)
               Local $char = StringSplit($readedText, "") ;store this to an array of characters
               Local $num = 0
               Local $iRound3 = 0
               Local $perc = $num&"%"
               
               ;start timer
               $begin = TimerInit()
               AdlibRegister("SetTime", 1000)
                           
               For $i = 1 to $char[0]
                  
                     Switch GUIGetMsg()
                     Case $stopButton ;if stop button has been clicked
                     ExitLoop ; Exit the loop
                     EndSwitch
                  
                  Local $volume  = GUICtrlRead ($volumeSlider, 0) ;read volume slider
                  SoundSetWaveVolume($volume) ; Set the volume
               
                  Local $play1 = "\alphabet\"
                  Local $play2 = ".wav"
                  SoundPlay(@ScriptDir &$play1&$char[$i]&$play2, 1)

                  $num = ((100*$char[0])/$char[0])-(((100*$char[0])/$char[0])-((100*$i)/$char[0]))
                  $iRound3 = Round($num)
                  $perc = $iRound3&"%"
               
                  If StringLen($perc) > 3 Then
                     $perc = "99%"
                     ; PROGRESS bar
                     GUICtrlCreateProgress(453, 293, 78, 20)
                     GUICtrlSetData(-1, $num)
                     GUICtrlCreateLabel("Progress:", 387, 295)
                     GUICtrlCreateLabel($perc, 535, 295)
                  Else
                     ; PROGRESS bar
                     GUICtrlCreateProgress(453, 293, 78, 20)
                     GUICtrlSetData(-1, $num)
                     GUICtrlCreateLabel("Progress:", 387, 295)
                     GUICtrlCreateLabel($perc, 535, 295)
                  EndIf
               
                  Sleep ($iDelay)
               Next
                  ; PROGRESS bar
                  GUICtrlCreateProgress(453, 293, 78, 20)
                  GUICtrlSetData(-1, (100*$char[0])/$char[0])
                  GUICtrlCreateLabel("Progress:", 387, 295)
                  Local $p2 = GUICtrlCreateLabel("100%", 535, 295)
                  ;wait a bit
                  Sleep(1000)
                  GUICtrlDelete($p2)
                  ; PROGRESS bar
                  GUICtrlCreateProgress(453, 293, 78, 20)
                  GUICtrlSetData(-1, 0)
                  GUICtrlCreateLabel("Progress:", 387, 295)
                  GUICtrlCreateLabel("0%", 535, 295)
                  
                  ;end timer
                  AdlibUnRegister("SetTime")
                  GUICtrlCreateLabel("00:00:00", 453, 325, 78, 20)
                  
               ; Enable the play and delay buttons
               GUICtrlSetState($playButton, $GUI_ENABLE)
               GUICtrlSetState($idCombo2, $GUI_ENABLE)
               
               















            Case $idDecodeButton
                ; When you press Decode

                ;start timer
                $begin = TimerInit()
                AdlibRegister("SetTime", 1000)
               
                ;Read text from input box
                Local $textTodecodeCaps = GUICtrlRead($idEditText)
                ;if input box is empty
                  If $textTodecodeCaps = "" Then
                     RestartScript()
                  Else
                ;convert all read text to lower case letters
                Local $textTodecode = StringLower($textTodecodeCaps)

               ; Friendly message to the text box
                GUICtrlSetData($idEditText, 'Wait for data processing. This may take a while...')

                ; PROGRESS bar
               GUICtrlCreateProgress(453, 293, 78, 20)
               GUICtrlSetData(-1, 10)
               GUICtrlCreateLabel("Progress:", 387, 295)
               GUICtrlCreateLabel("10%", 535, 295)


               ;DECRYPT DECODED DATA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
               ;If the password box is empty, do not use encryption
               If GuiCtrlRead($idInputPass) = "" Then
                  ;Encode the contents of the non encrypted variable to zbase32
                  $decodedDataZIP = _Base32_Decode($textTodecode)

               ; PROGRESS bar
               GUICtrlCreateProgress(453, 293, 78, 20)
               GUICtrlSetData(-1, 20)
               GUICtrlCreateLabel("Progress:", 387, 295)
               GUICtrlCreateLabel("20%", 535, 295)

               ;If password box is not empty then use decryption
               Else

                  ;Decode the contents of the variable to zbase32
                  Local $decodedData = _Base32_Decode($textTodecode)

                  ; Calls the decryption.
                $decodedDataZIP = _Crypt_DecryptData($decodedData, GUICtrlRead($idInputPass), $iAlgorithm) ; Encrypt the text with the new cryptographic key.

               ; PROGRESS bar
               GUICtrlCreateProgress(453, 293, 78, 20)
               GUICtrlSetData(-1, 20)
               GUICtrlCreateLabel("Progress:", 387, 295)
               GUICtrlCreateLabel("20%", 535, 295)
            EndIf

;;;;;;;;;;;;;; WRITE DECODED AND/OR DECRYPTED DATA TO ZIP FILE ;;;;;;;;;;;;;;;;

               ;$theTMPfile is the tmp zip file and its path
               Local $theTMPfile = @TempDir&"\tmp2.zip"

               ; Open the file for writing (append to the end of a file) and store the handle to a variable.
               Local $rFileOpen = FileOpen($theTMPfile, $FO_OVERWRITE)
                  If $rFileOpen = -1 Then
                     GUICtrlSetData($idEditText, "An error occurred when reading the file.")
                     Return False
                  EndIf

               ; PROGRESS bar
               GUICtrlCreateProgress(453, 293, 78, 20)
               GUICtrlSetData(-1, 40)
               GUICtrlCreateLabel("Progress:", 387, 295)
               GUICtrlCreateLabel("40%", 535, 295)

               ; Write data to the file using the handle returned by FileOpen.
               FileWrite($rFileOpen, $decodedDataZIP)

               ; Close the handle returned by FileOpen.
               FileClose($rFileOpen)

               ; PROGRESS bar
               GUICtrlCreateProgress(453, 293, 78, 20)
               GUICtrlSetData(-1, 60)
               GUICtrlCreateLabel("Progress:", 387, 295)
               GUICtrlCreateLabel("60%", 535, 295)

;;;;;;;;;;;;;; UNZIP THE ZIP FILE ;;;;;;;;;;;;;;;;
               ;Local $tmpTextfile2 = @TempDir&"\tmp2.txt"
               ;Local $DataText_received_files = @ScriptDir&"\DataText_received_files"
               ;Local $DataText_all_files = @ScriptDir&"\DataText_all_files"
               
                ;    FileDelete($tmpTextfile2)
                     ;Set the parameters of the create zip command
                ;    Local $param1a = @ScriptDir&"\7z.exe "
                ;    Local $param3a = "x "
                ;    Local $param4a = " -o"
                ;    Local $param7a = " > "
                     ;Extract zip to DataText_received_files dir
                ;   RunWait($param1a&$param3a&$theTMPfile&$param4a&$DataText_received_files&$param7a&$tmpTextfile2, "", @SW_HIDE)
                    ;Extract zip to DataText_all_files dir
                ;   RunWait($param1a&$param3a&$theTMPfile&$param4a&$DataText_all_files&$param7a&$tmpTextfile2, "", @SW_HIDE)
              ; GUICtrlSetData($idEditText, $param1a&$param3a&$theTMPfile&$param4a&$DataText_received_files&$param7a&$tmpTextfile2)
              ; Sleep(10000)
               
               _Zip_UnzipAll($theTMPfile, @ScriptDir&"\DataText_received_files");unzip contents to DataText_received_files dir
               _Zip_UnzipAll($theTMPfile, @ScriptDir&"\DataText_all_files");unzip contents to DataText_all_files dir
               

               ; PROGRESS bar
               GUICtrlCreateProgress(453, 293, 78, 20)
               GUICtrlSetData(-1, 80)
               GUICtrlCreateLabel("Progress:", 387, 295)
               GUICtrlCreateLabel("80%", 535, 295)

               ; Delete the temporary tmp.zip file.
                FileDelete($theTMPfile)

               ; Put initial encoded data to text box
               GUICtrlSetData($idEditText, $textTodecode)

               ; PROGRESS bar
               GUICtrlCreateProgress(453, 293, 78, 20)
               GUICtrlSetData(-1, 100)
               GUICtrlCreateLabel("Progress:", 387, 295)
               Local $p3 = GUICtrlCreateLabel("100%", 535, 295)

               ;wait a bit
                  Sleep(1000)
                  GUICtrlDelete($p3)

               ; PROGRESS bar
               GUICtrlCreateProgress(453, 293, 78, 20)
               GUICtrlSetData(-1, 0)
               GUICtrlCreateLabel("Progress:", 387, 295)
               GUICtrlCreateLabel("0%", 535, 295)
               
               ;end timer
               AdlibUnRegister("SetTime")
               GUICtrlCreateLabel("00:00:00", 453, 325, 78, 20)
               
               ;open explorer window to see file
               Local $sDir = @ScriptDir & "\DataText_received_files"
               Local $windowtitle = "DataText_received_files"
               Run("explorer.exe " & $sDir);open explorer to see extracted files in folder
               Local $hExplorer = WinWait("[REGEXPTITLE:(?i)\Q" & $windowtitle & "\E$]")
               WinWaitClose($hExplorer)

               DirRemove(@ScriptDir&"\DataText_received_files",1); when files have been viewed, delete the DataText_received_files dir
               DirCreate(@ScriptDir&"\DataText_received_files");recreate the DataText_received_files dir
            
   EndIf
               









            Case $idInfoButton
               ;When you press ?

               ; Info message to the text box
                GUICtrlSetData($idEditText, "DataText by sv3ora"&@crlf&"Conversion of file to text and text to file."&@crlf&@crlf&"This program can be used to transfer data through any radio amateur digital mode "&@crlf&"(including CW), that supports text-only transmission"&@crlf&@crlf&"TO ENCODE A FILE:"&@crlf&"1. Click 'Encode' to select the file to encode."&@crlf&"2. Select all encoded text (right click) and copy it."&@crlf&"3. Paste this text to your favorite sending program."&@crlf&"If you want to password protect your file, enter a password and select the"&@crlf&"encryption algorithm from the drop down list, prior to clicking the encode button."&@crlf&@crlf&"TO DECODE A TEXT:"&@crlf&"1. Copy the text to decode from your favorite receiving"&@crlf&"     program and paste it into this text box."&@crlf&"2. Click 'Decode' to decode this text."&@crlf&"3. The decoded file is automatically displayed in a new explorer window."&@crlf&"If the received data has been password protected, then you have to enter the"&@crlf&"password and select the encryption algorithm from the drop down list,"&@crlf&"prior to clicking the decode button. "&@crlf&@crlf&"Note that DataText keeps all your previously decoded files into the 'DataText_all_files' "&@crlf&"directory, inside the folder where the DataText program is."&@crlf&@crlf&"EMBEDDED PLAYER: "&@crlf&"The embedded player, can be used to play any text (encoded or not) in the text area "&@crlf&"into phonetic alphabet. Set the delay between letters and click 'Play' to play the text."&@crlf&"The playback volume can be set at any time and the playback can be stopped "&@crlf&"by clicking 'Stop'."&@crlf&@crlf&"PROGRESS:"&@crlf&"The progress bar, shows the encoding, decoding and playback progress."&@crlf&"The elapsed time is also displayed during encoding, decoding and playback."&@crlf&@crlf&"More info about DataText at:  http://www.qrp.gr/datatext"&@crlf&"Comments and suggestions at:  sv3ora@qrp.gr")

        EndSwitch
    WEnd
EndFunc   ;==>_Main

 

Link to comment
Share on other sites

I cant see where you are creating a "tmp.txt" file, only deleting it.

Also what is the purpose of the trailing ">" in $param7 ?

​The tmp.txt file is created (I hope) by the 7zip. The output messages of 7zip are redirected in this file instead of being displayed in the terminal. I have used the @SW_HIDE flag but just in case.

Link to comment
Share on other sites

Local $param1 = @ScriptDir&"\7z.exe "
Local $param3 = "a -tzip -aoa -mx=9 "
Local $param4 = @TempDir&"\tmp.zip "
Local $param7 = " > "
;Create zip
Local $sRun = $param1&$param3&$param4&$sFileOpenDialog&$param7&$tmpTextfile
ConsoleWrite(' $sRun >'&$sRun&'<'&@CRLF) ; ..this way you can see what is gonna execute
RunWait($sRun, "", @SW_HIDE)

 

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

 

Local $param1 = @ScriptDir&"\7z.exe "
Local $param3 = "a -tzip -aoa -mx=9 "
Local $param4 = @TempDir&"\tmp.zip "
Local $param7 = " > "
;Create zip
Local $sRun = $param1&$param3&$param4&$sFileOpenDialog&$param7&$tmpTextfile
ConsoleWrite(' $sRun >'&$sRun&'<'&@CRLF) ; ..this way you can see what is gonna execute
RunWait($sRun, "", @SW_HIDE)

 

 

​The console message is

$sRun >C:\Users\giannopk\Desktop\DataText_dev\7z.exe a -tzip -aoa -mx=9 C:\Users\giannopk\AppData\Local\Temp\tmp.zip C:\Users\giannopk\Desktop\slider\img\left.png > C:\Users\giannopk\AppData\Local\Temp\tmp.txt<

 

Link to comment
Share on other sites

I can reproduce by just running the command from the commandline. Meaning it's not an AutoIt problem (or a problem in your code) but some sort of 7zip strangeness.

Just for completeness' sake, my command was:
C:\tmp> "C:\Program Files (x86)\7-Zip\7z.exe" a -tzip -aoa -mx=9 c:\tmp\tmp.zip c:\tmp\txt.txt

... and the zipfile contains:
2015-01-10 16:08:40 D....            0            0  7-Zip (<-- empty folder)
2015-05-24 03:09:48 ....A          229           26  txt.txt

Funny thing... If I run it on the CLI from path, i.e. without the full path to 7z.exe, it works fine. This does not create the 7-Zip folder:
C:\tmp> 7z.exe a -tzip -aoa -mx=9 c:\tmp\tmp.zip c:\tmp\txt.txt

GOT IT! :) You need the -w switch. The usage info says: -w[{path}]: assign Work directory. Empty path means a temporary directory

This works fine: 
C:\tmp> "C:\Program Files (x86)\7-Zip\7z.exe" a -tzip -aoa -mx=9 -w"c:\tmp" c:\tmp\tmp.zip c:\tmp\txt.txt

That should do it. Good luck :)
Edited by SadBunny

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

I can reproduce by just running the command from the commandline. Meaning it's not an AutoIt problem (or a problem in your code) but some sort of 7zip strangeness.

Just for completeness' sake, my command was:
C:\tmp> "C:\Program Files (x86)\7-Zip\7z.exe" a -tzip -aoa -mx=9 c:\tmp\tmp.zip c:\tmp\txt.txt

... and the zipfile contains:
2015-01-10 16:08:40 D....            0            0  7-Zip (<-- empty folder)
2015-05-24 03:09:48 ....A          229           26  txt.txt

Funny thing... If I run it on the CLI from path, i.e. without the full path to 7z.exe, it works fine. This does not create the 7-Zip folder:
C:\tmp> 7z.exe a -tzip -aoa -mx=9 c:\tmp\tmp.zip c:\tmp\txt.txt

GOT IT! :) You need the -w switch. The usage info says: -w[{path}]: assign Work directory. Empty path means a temporary directory

This works fine: 
C:\tmp> "C:\Program Files (x86)\7-Zip\7z.exe" a -tzip -aoa -mx=9 -w"c:\tmp" c:\tmp\tmp.zip c:\tmp\txt.txt

That should do it. Good luck :)

​Thanks for the great info, but unfortunatelly it did not works.

That is weird, if I run the command from the terminal everything works fine

C:\Users\giannopk\Desktop\DataText_dev\7z.exe a -tzip -aoa -mx=9 C:\Users\giannopk\AppData\Local\Temp\tmp.zip C:\Users\giannopk\Desktop\slider\img\left.png > C:\Users\giannopk\AppData\Local\Temp\tmp.txt

In that case both the tmp.zip is created and also the tmp.txt

 

And even if I leave out the paths in the script the same faulty behaviour happens

7z.exe a -tzip -aoa -mx=9 tmp.zip C:\Users\giannopk\Desktop\slider\img\left.png > tmp.txt

 

Edited by neazoi
Link to comment
Share on other sites

All commands run fine for me, it's just that if I don't specify the working directory, an empty directory is included in my zipfile (when I don't specify a working dir using the -w switch, that is). Thought that was what you meant, maybe I misunderstood.

But try it with the -w switch.

Edited by SadBunny

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

All commands run fine for me, it's just that if I don't specify the working directory, an empty directory is included in my zipfile (when I don't specify a working dir using the -w switch, that is). Thought that was what you meant, maybe I misunderstood.

But try it with the -w switch.

​I have tried it with the -W switch including a tmp directory and still the same behaviour :(

I have also tried it calling the 7z.exe without a path.

 

UPDATE: I finally spotted the error. It was the redirection to the temporary txt file. I do not know why it caused this.

I also found thet with the @SW_HIDE flag, no terminal window appears, so it is fine not to use the redirection file.

Thanks for the help!

Edited by neazoi
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...