famko Posted March 29, 2016 Share Posted March 29, 2016 . 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 Link to comment Share on other sites More sharing options...
orbs Posted March 29, 2016 Share Posted March 29, 2016 @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. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
famko Posted March 29, 2016 Author Share Posted March 29, 2016 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 Link to comment Share on other sites More sharing options...
orbs Posted March 29, 2016 Share Posted March 29, 2016 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. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
famko Posted March 29, 2016 Author Share Posted March 29, 2016 Thanks orbs, perfect!! did try something similar, but never used the '&$pcid&' between the quotes. Thank you! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now