7zip basic script
-
serendipity
- Posts: 3360
- Joined: 07 May 2007 18:14
- Location: NJ/NY
7zip basic script
Donot use this script, see next post.
I made some simple scripts for compressing and extracting files with 7zip, here is the script file:
//7-Zip script files
"Open Zipfile : open"
openwith "%programfiles%\7-Zip\7zFM.exe"
-
"&Zip files : zip"
//Compress file with .zip. Name= base of file.
openwith """%programfiles%\7-Zip\7z.exe"" a -tzip "<curbase>""
"&7z files : 7z"
//Compress file with .7z. Name= base of file.
openwith """%programfiles%\7-Zip\7z.exe"" a -t7z "<curbase>""
"&Extract : ext"
//Extract content to folder Name= base of zip.
openwith """%programfiles%\7-Zip\7z.exe"" x -aot"
-
"Zi&p files (with password) : pzip"
input $i, Input password for zipfile, password;
//Compress with .zip and password protect archive.
openwith """%programfiles%\7-Zip\7z.exe"" a -tzip "<curbase>" -p$i"
"7z files (&with password) : p7z"
input $i, Input password for zipfile, password;
//Compress with 7z and password protect and encrypt archive.
openwith """%programfiles%\7-Zip\7z.exe"" a -t7z "<curbase>" -p$i -mhe"
These are ofcourse very basic because with 7zip you can control lot of things like level of compression, self-extracting archives etc.
I made some simple scripts for compressing and extracting files with 7zip, here is the script file:
//7-Zip script files
"Open Zipfile : open"
openwith "%programfiles%\7-Zip\7zFM.exe"
-
"&Zip files : zip"
//Compress file with .zip. Name= base of file.
openwith """%programfiles%\7-Zip\7z.exe"" a -tzip "<curbase>""
"&7z files : 7z"
//Compress file with .7z. Name= base of file.
openwith """%programfiles%\7-Zip\7z.exe"" a -t7z "<curbase>""
"&Extract : ext"
//Extract content to folder Name= base of zip.
openwith """%programfiles%\7-Zip\7z.exe"" x -aot"
-
"Zi&p files (with password) : pzip"
input $i, Input password for zipfile, password;
//Compress with .zip and password protect archive.
openwith """%programfiles%\7-Zip\7z.exe"" a -tzip "<curbase>" -p$i"
"7z files (&with password) : p7z"
input $i, Input password for zipfile, password;
//Compress with 7z and password protect and encrypt archive.
openwith """%programfiles%\7-Zip\7z.exe"" a -t7z "<curbase>" -p$i -mhe"
These are ofcourse very basic because with 7zip you can control lot of things like level of compression, self-extracting archives etc.
Last edited by serendipity on 18 Sep 2008 21:56, edited 1 time in total.
-
serendipity
- Posts: 3360
- Joined: 07 May 2007 18:14
- Location: NJ/NY
Update: 23 Oct '08
The above script will not work if you make selections using selection rectangle. See here. With some help from Jacky, I am updating the above script.
The above script will not work if you make selections using selection rectangle. See here. With some help from Jacky, I am updating the above script.
Code: Select all
//7-Zip script files
"Open Zipfile : open"
openwith "%programfiles%\7-Zip\7zFM.exe"
-
"&Zip files : zip"
focus;
#113;
focus;
set $curbase, <clipboard>;
strlen $l, $curbase;
strpos $p, $curbase, <crlf>;
regexreplace $p, $p, "^-1$", "$l";
substr $curbase, $curbase, 0, $p;
replace $curbase, $curbase," ","_";
//Compress file with .zip. Name= base of file.
openwith """%programfiles%\7-Zip\7z.exe"" a -tzip ""$curbase.zip"""
"&7z files : 7z"
focus;
#113;
focus;
set $curbase, <clipboard>;
strlen $l, $curbase;
strpos $p, $curbase, <crlf>;
regexreplace $p, $p, "^-1$", "$l";
substr $curbase, $curbase, 0, $p;
replace $curbase, $curbase," ","_";
//Compress file with .7z. Name= base of file.
openwith """%programfiles%\7-Zip\7z.exe"" a -t7z ""$curbase.7z"""
-
"&Extract : ext"
//Extract content to folder Name= base of zip. aot= If files exist, autonumber new files.
openwith "%programfiles%\7-Zip\7z.exe" x -aot
"&Extract (to folder) : extf"
// Copy item/pathname to cilpboard
openwith """C:\Program Files\7-Zip\7z.exe"" x -y -o* -aot <items>"
-
"Zi&p files (with password) : pzip"
focus;
#113;
focus;
set $curbase, <clipboard>;
strlen $l, $curbase;
strpos $p, $curbase, <crlf>;
regexreplace $p, $p, "^-1$", "$l";
substr $curbase, $curbase, 0, $p;
replace $curbase, $curbase," ","_";
set $curbase, "$curbase.zip";
input $i, Input password for zipfile, password;
//Compress with .zip and password protect archive.
openwith """%programfiles%\7-Zip\7z.exe"" a -tzip $curbase -p$i"
"7z files (&with password) : p7z"
focus;
#113;
focus;
set $curbase, <clipboard>;
strlen $l, $curbase;
strpos $p, $curbase, <crlf>;
regexreplace $p, $p, "^-1$", "$l";
substr $curbase, $curbase, 0, $p;
replace $curbase, $curbase," ","_";
set $curbase, "$curbase.7z";
input $i, Input password for zipfile, password;
//Compress with 7z and password protect and encrypt archive headers.
openwith """%programfiles%\7-Zip\7z.exe"" a -t7z $curbase -p$i -mhe"
Last edited by serendipity on 24 Oct 2008 04:32, edited 5 times in total.
-
lukescammell
- Posts: 744
- Joined: 28 Jul 2006 13:15
- Location: Kent, UK
- Contact:
Re: 7zip basic script
Code: Select all
"&Extract : ext"
//Extract content to folder Name= base of zip.
//aot= If files exist, autonumber new files.
openwith """%ProgramW6432%\7-Zip\7z.exe"" x -aot -o./newly-extracted-files"P.S. Don, you need to change your style sheets as the forum is stripping out white space from the code examples! Change white-space: normal; to white-space: pre;
Used to update to the latest beta every day. Now I have children instead…
Windows 10 Pro x64 (everywhere except phone…)
Windows 10 Pro x64 (everywhere except phone…)
-
admin
- Site Admin
- Posts: 64858
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: 7zip basic script
Great, that was easy!lukescammell wrote:P.S. Don, you need to change your style sheets as the forum is stripping out white space from the code examples! Change white-space: normal; to white-space: pre;
Here's a tip for you. Use outer single quotes to avoid the need to double the double quotes:
Code: Select all
OLD: openwith """%ProgramW6432%\7-Zip\7z.exe"" x -aot -o./newly-extracted-files"
NEW: openwith '"%ProgramW6432%\7-Zip\7z.exe" x -aot -o./newly-extracted-files'
FAQ | XY News RSS | XY X
-
admin
- Site Admin
- Posts: 64858
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: 7zip basic script
I had to take it back!admin wrote:Great, that was easy!lukescammell wrote:P.S. Don, you need to change your style sheets as the forum is stripping out white space from the code examples! Change white-space: normal; to white-space: pre;![]()
Code: Select all
set $a, "it is <date hh:nn:ss>";
$b = "it is <date hh:nn:ss>";
msg "$a<br>$b";FAQ | XY News RSS | XY X
-
admin
- Site Admin
- Posts: 64858
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: 7zip basic script
I had to take it back!admin wrote:Great, that was easy!lukescammell wrote:P.S. Don, you need to change your style sheets as the forum is stripping out white space from the code examples! Change white-space: normal; to white-space: pre;![]()
However, I found that I have no problems keeping white space without white-space: pre. See this (copied from UltraEdit, real white space, no tabs):
Code: Select all
set $a, "it is <date hh:nn:ss>";
$b = "it is <date hh:nn:ss>";
msg "$a<br>$b";FAQ | XY News RSS | XY X
Re: 7zip basic script
Well, I know I noticed that the first spaces were eaten up, so I always try to put two spaces at the beginning of each line, cause then they remain. See:
As for the cause of this, might be that phpBB that doesn't convert single space to
Code: Select all
"single space"
set $a, "foobar";
msg $a;
"double space"
set $a, "foobar";
msg $a;Proud XYplorer Fanatic
-
serendipity
- Posts: 3360
- Joined: 07 May 2007 18:14
- Location: NJ/NY
Re: 7zip basic script
This is a bit longer script but will extract the archive to the folder with the same name.lukescammell wrote:This extracts the contents of the archive to a folder called "newly-extracted-files" in the same location as the archive. How can I get this "newly-extracted-files" folder to be named by the name of the archive file being extracted?Code: Select all
"&Extract : ext" //Extract content to folder Name= base of zip. //aot= If files exist, autonumber new files. openwith """%ProgramW6432%\7-Zip\7z.exe"" x -aot -o./newly-extracted-files"
Code: Select all
"&Extract (to folder) : extf"
//Copy item/pathname to clipboard
#101;
focus;
set $toextract, <clipboard>;
focus;
//Copy item base to clipboard
#113;
focus;
set $curbase, <clipboard>;
//Create new folder based on archive's name
new $curbase, dir;
set $curpath, <curitem>;
goto $toextract;
//Extract content to folder Name= base of zip. aot= If files exist, autonumber new files.
openwith """%programfiles%\7-Zip\7z.exe"" x -o"$curpath" -aot"
-
admin
- Site Admin
- Posts: 64858
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: 7zip basic script
Aha! Good find!jacky wrote:Well, I know I noticed that the first spaces were eaten up, so I always try to put two spaces at the beginning of each line, cause then they remain. See:As for the cause of this, might be that phpBB that doesn't convert single space to Code: Select all
"single space" set $a, "foobar"; msg $a; "double space" set $a, "foobar"; msg $a;
FAQ | XY News RSS | XY X
-
lukescammell
- Posts: 744
- Joined: 28 Jul 2006 13:15
- Location: Kent, UK
- Contact:
Re: 7zip basic script
This is creating the folder, but not putting anything into it :/serendipity wrote:This is a bit longer script but will extract the archive to the folder with the same name.lukescammell wrote:How can I get this "newly-extracted-files" folder to be named by the name of the archive file being extracted?Code: Select all
"&Extract (to folder) : extf" //Copy item/pathname to clipboard #101; focus; set $toextract, <clipboard>; focus; //Copy item base to clipboard #113; focus; set $curbase, <clipboard>; //Create new folder based on archive's name new $curbase, dir; set $curpath, <curitem>; goto $toextract; //Extract content to folder Name= base of zip. aot= If files exist, autonumber new files. openwith """%programfiles%\7-Zip\7z.exe"" x -o"$curpath" -aot"
Regarding the strangeness with the code boxes - none of the strangeness should be happeneing, it's wrong. The whole point of the code tags is that it isn't meant to change anything in the text... wierd :/
Used to update to the latest beta every day. Now I have children instead…
Windows 10 Pro x64 (everywhere except phone…)
Windows 10 Pro x64 (everywhere except phone…)
-
serendipity
- Posts: 3360
- Joined: 07 May 2007 18:14
- Location: NJ/NY
Re: 7zip basic script
Hmmm strange, works here for me. Tried on a second PC now and works there too. What does stepping through scripts reveal?
-
admin
- Site Admin
- Posts: 64858
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: 7zip basic script
They don't use <code> tags. It's a <div> with some properties.lukescammell wrote:Regarding the strangeness with the code boxes - none of the strangeness should be happeneing, it's wrong. The whole point of the code tags is that it isn't meant to change anything in the text... wierd :/
FAQ | XY News RSS | XY X
-
lukescammell
- Posts: 744
- Joined: 28 Jul 2006 13:15
- Location: Kent, UK
- Contact:
Re: 7zip basic script
They do..
Unfortunately, they also do horrible, HORRIBLE things like put br tags in the code, GAH! No wonder there's all sorts of problems. PHPBB should know better (there shold only ever be text inside code tags, that's supposed to be the whole point)...
Back OT a bit, but is there a way to make this script popup when I right click on a 7z and/or rar/zip/etc file?
Code: Select all
<dl class="codebox"><dt>Code: <a href="#" onclick="selectCode(this); return false;">Select all</a></dt><dd><code>"&Extract (to folder) : extf"<br /> //Copy item/pathname to clipboard<br /> #101; <br /> focus; <br /> set $toextract, <clipboard>; <br /> focus;<br /> //Copy item base to clipboard<br /> #113; <br /> focus;<br /> set $curbase, <clipboard>; <br /> //Create new folder based on archive's name<br /> new $curbase, dir;<br /> set $curpath, <curitem>;<br /> goto $toextract;<br /> //Extract content to folder Name= base of zip. aot= If files exist, autonumber new files.<br /> openwith """%programfiles%\7-Zip\7z.exe"" x -o"$curpath" -aot"<br /></code></dd></dl>Back OT a bit, but is there a way to make this script popup when I right click on a 7z and/or rar/zip/etc file?
Used to update to the latest beta every day. Now I have children instead…
Windows 10 Pro x64 (everywhere except phone…)
Windows 10 Pro x64 (everywhere except phone…)
-
admin
- Site Admin
- Posts: 64858
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: 7zip basic script
Oh yes, they do use <code>.
Not yet. Will come with custom events.lukescammell wrote:Back OT a bit, but is there a way to make this script popup when I right click on a 7z and/or rar/zip/etc file?
FAQ | XY News RSS | XY X
Re: 7zip basic script
This is a little late and possibly slightly ot but I have a UDC setup using 7-zip that extracts archive(s) into folders based on the archive name. A little warning though, it will overwrite any files of the same name if there is already an existing folder with the archive's name without a prompt.
It works fine with single/multiple selections and it also works when drawing a rectangle around multiple items.
The path assumes you installed 7-zip to program files\7-zip so modify accordingly.
"C:\Program Files\7-Zip\7z.exe" x -y -o* <items>
It works fine with single/multiple selections and it also works when drawing a rectangle around multiple items.
The path assumes you installed 7-zip to program files\7-zip so modify accordingly.
"C:\Program Files\7-Zip\7z.exe" x -y -o* <items>
XYplorer Beta Club