Jump to content

[Solved] Problem with Gzip


Recommended Posts

Hello,

I need to compress a file with a name including space "test file.bin".

In my script directory, I have put the gzip directory.

I've tested using the "Run" command and it works fine if I remove the space in the file name but not if I let it.

Then I testes using the "ShellExecute " command...

My FileMove doesn't seem to work either.

$FileName = @ScriptDir
$FileName = FileSaveDialog("Select a file", $FileName, "(*.bin)", 2)

$i_FileSize = FileGetSize($FileName)
                                                                    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $i_FileSize = ' & $i_FileSize & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
Compress($FileName)
$i_FileSize = FileGetSize($FileName)
                                                                    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $i_FileSize = ' & $i_FileSize & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console

Exit

Func Compress($FileName)
    Local $s_WorkFile = @ScriptDir & "\Work.tmp", $s_File = $FileName   
    FileCopy($s_File, $s_WorkFile, 9)
;   $com = ".\gzip\gzip -f4 " & Chr(34) & $s_WorkFile & Chr(34)
;   Run($com, "", @SW_HIDE)
    ShellExecute(".\gzip\gzip.exe", "-f4 " & Chr(34) & $s_WorkFile & Chr(34), "", "", @SW_HIDE)
    $s_WorkFile = $s_WorkFile & ".gz"
                                                                    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $s_WorkFile = ' & $s_WorkFile & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
                                                                    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $s_File = ' & $s_File & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
    FileMove($s_WorkFile, $s_File, 1)
EndFunc

Edit: I find the solution myself using the command ShellExecuteWait instead of ShellExecute. :whistle:

Edited by Starcom
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...