famko

7zip and @comspeq

5 posts in this topic

.

Hi everyone

I have made a script to save  a htm-file, after entering  a pcid into a zip file . The script is working  but it takes all the files in the folder and put it into the zip. I don’t know how to use 7zip commandline switches  in combination with @comspeq  so  that just the file I needed will be zipped.

Can anyone help me?

 

#include <MsgBoxConstants.au3>
#include <FileConstants.au3>

inputpcid()

Func inputpcid()

    Local $pcid = InputBox("PCID", "Vul het Pcid in:", "", "", _
             - 1, -1, 0, 0)


$check = MsgBox(4, "pcid?",  "Is dit het juiste pcid?    " & $pcid)
If $check = 6 Then

ElseIf $check = 7 Then
   inputpcid()
EndIf

Run(@comspec & " /c 7za.exe a " & $pcid )


sleep (2000)


FileMove("*.7z", $pcid & ".zip")


EndFunc

testinput.au3

Share this post


Link to post
Share on other sites



@famko,

@comspec is not your issue. you are not telling 7za.exe which file you want to add to the archive, so it (presumably) defaults to the entire working directory.

look closely at the command line switches - switch a works with two arguments: the first is the destination archive name, and the 2nd is the files to archive.

b.t.w i cannot understand what is the point of the last FileMove. you should simply specify the archive file name as the final target path when you call 7za.exe. also, calling a function recursively like that is not proper practice (although it may even work... ;) ).

and use the code tags when you post code to the forum - that's the  < >  icon in the toolbar. that way the script is well presented, and no need to attach it separately.

 

Share this post


Link to post
Share on other sites

Thanks for your answer orbs,

i know that the problem are the commandline switches , but i can't get them to work. 

I am trying to get: System Info.htm into a zip. The name of the zip files must be $pcid.

The htm file has a space in the name, that’s required , I cannot change this. Same thing with the zip file , it has to be zip, not 7z.

The reason i use filemove, is that when i use 7zip with @comspeq it uses the 7z format instead of the zip format. When I run it from the dos prompt it uses the zip format, so @comspeqs is treating 7zip different then the dos prompt.

There is no switch to tell 7zip to use the zip format.

Hope you can help me.

#include <MsgBoxConstants.au3>
#include <FileConstants.au3>

inputpcid()

Func inputpcid()

    Local $pcid = InputBox("PCID", "Vul het Pcid in:", "", "", _
             - 1, -1, 0, 0)


$check = MsgBox(4, "pcid?",  "Is dit het juiste pcid?    " & $pcid)
If $check = 6 Then

ElseIf $check = 7 Then
   inputpcid()
EndIf

Run(@comspec & " /c 7za.exe a " & $pcid )


sleep (2000)


FileMove("*.7z", $pcid & ".zip")


EndFunc

 

Share this post


Link to post
Share on other sites
Run('7za.exe -tzip a '&$pcid&' "system info.htm"')

the switch -t sets the archive type, specifically -tzip sets the archive to zip.

the file to be zipped, when contains whitespace in name, should be enclosed in double-quotes. that's why i enclosed the string passed to the Run() command in single-quotes.

also, pay close attention not to miss the whitespaces before and after $pcid.

 

Share this post


Link to post
Share on other sites

Thanks orbs, perfect!!

did try something similar, but never used the '&$pcid&' between the quotes.

Thank you!

Share this post


Link to post
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