I am thankful for the previous posts from PeterH , 40k and TheQwerty.
I had not been satisfied completely with what I had achieved,
so after further attempts at trying to get better results, I finally arrived at
the examples shown as follows. Of course the main aim was to reduce the risks concerning
spaces in paths. At end of post are the full scripts one using single quotes named "7zip2013b.xys"
and one using the Heredoc method named "7zip2013c.xys".
In conclusion the three different methods all have their pros and cons.
Method 1 (all double quotes) hard to get to work with spaces in paths.
Method 2 (single & double quotes) easier.
Method 3 (Heredoc) easiest to use but found had to juggle switches.(not a big problem).
Code: Select all
"_Initialize";
//this has been tested on win7 64bit and XP
perm $p_zip = '"C:\Users\user\Documents\Virtual Machines\zTemp\7-Zip\7z.exe"' ;
perm $p_ZipFM ="C:\Users\user\Documents\Virtual Machines\zTemp\7-Zip\7zFM.exe";
perm $p_note = '"C:\Users\user\Documents\Virtual Machines\zTemp\ConTEXT\ConTEXT.exe"';
"&Open <curname> : open"
openwith $p_ZipFM;
Further are examples from each section.
Code: Select all
"List <curname> single"
run'cmd /c "'.$p_zip.' l "'.<curitem>.'" >"'.<curitem>.".txt".'"';
-
"7-Zip and move into <curbase>.&7z and move : 7zm"
$a = get("path", i);
openwith ''.$p_zip.' a -t7z "'.$a\.<curbase>.".7z".'"';
-
"Compress into <curbase>.&zip : zip"
focus;
#113;
focus;
$curbase = <clipboard>;
$l = strlen ($curbase);
$p = strpos ($curbase, <crlf>);
$curbase = regexreplace ($curbase,"^-1$","$l");
if ($p =="-1") { $p = $l ; } // if single item selected
$curbase = substr ($curbase, 0, $p);
$curbase = replace ($curbase,"","_");
set $curbase,"$curbase.zip";
//Compress file with .zip. Name= base of file.
openwith ''.$p_zip.' a -tzip "'.$curbase.'"';
-
"&Extract contents of <curname> to <curbase> other pane (overwrite NO warning) : extfop"
$a = get("path", i);
openwith''.$p_zip.' x -y -o"'.$a\<curbase>\.'" <items>' ;
-
"Compress into <curbase>.zi&p (password protection) : pzip"
focus;
#113;
focus;
$curbase= <clipboard>;
$l = strlen ($curbase);
$p = strpos ($curbase, <crlf>);
$curbase = regexreplace ($curbase,"^-1$","$l");
if ($p =="-1") { $p = $l ; } // if single item selected
$curbase = substr ($curbase, 0, $p);
$curbase = replace ($curbase," ","_");
set $curbase,"$curbase.zip";
$i = input (Input password for zipfile, password);
//Compress with .zip and password protect archive.
openwith''.$p_zip.' a -tzip "'.$curbase.'" -p"'.$i.'"';
-
"?Set Password to <curname> zip : zp"
set $file, <curbase>;
openwith''.$p_zip.' x -y "'.<items>.'"' ;
msg"wait until extract",1;
focus ;
filter $file* ;
delete 0 , 0 ;
sortby created, d ;
sel 1 ;
sub pzip ;
filter $file ;
-
-
"Edit script : edit"
$ScriptFile= self ("file");
run $p_note "$ScriptFile" ,w;
totmad1(totally mad one)
Update 18/07/2013
Had further thoughts on Set password to 7z. I came up with the idea of extracting to a folder named zTmp.
So produced the following code
Code: Select all
"?Set Password to <curbase> .7z(extract to zTmp) : z7"
set $file, <curbase>; set $Path1, <curpath>;
// change zTmp in cmd line and goto "$Path1\ to suit you
$cmdline = <<<CMD_LINE
cmd /c "$p_zip x "<curitem>" -aou -o"zTmp\"
CMD_LINE;
$cmdline = Replace($cmdline, "<crlf>", ' ');
Run($cmdline, , 0, 0);
msg"wait until extract",1;
goto "$Path1\zTmp";
sel a;
sub p7z;
msg "don't forget to move (7z'd) file,<br> then delete zTmp folder and original archive";