Help With Script Involving 7-Zip.

Discuss and share scripts and script files...
Post Reply
Lare2
Posts: 65
Joined: 18 Sep 2006 08:29

Help With Script Involving 7-Zip.

Post by Lare2 »

I'm after a script that will extract a zip file and to the same folder and then then delete the zip file it just extracted.

I've done some pretty basic scripts, no one of them with more than 4 lines, so this is clearly out of my expertise.

OK so this is in detail what i want it to do.

1.- I will select "test.zip" file.
2.- The script will extract the selected "test.zip" file to the same folder.
3.- the script will delete the "test.zip" (or better yet, send it to the recycle bin)


I have the 7-Zip program installed on my machine. I was planing on using the "7zG.exe" file. Something like "7zG.exe e <Zip File>"

Can some one point me in the right direction. Or do something for me that could do this so i can understand how it works and adapt it.

For those without 7-Zip installed here's the Help File

Thank you in advance to all taking the time to read this.

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Re: Help With Script Involving 7-Zip.

Post by jacky »

I don't have 7z and I haven't tested this, so use with care and test it first, but I think something like this should do it (once you're put the correct path to your 7zG.exe of course) :

Code: Select all

	run """C:\Program Files\7z\7zG.exe"" x ""<curitem>""",,1; // launch extraction and waits until its over
	delete 1, 0, <curitem>; // sends to recycle bin
Proud XYplorer Fanatic

serendipity
Posts: 3358
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Help With Script Involving 7-Zip.

Post by serendipity »

Yup, Jacky's script will work. But if your archive content is not within a folder then the contents will be extracted outside. To make sure that your content is always inside a folder, use this.

Code: Select all

//Extract archive contents inside a folder and delete archive
    run """C:\Program Files\7-Zip\7zG.exe"" x -y -o* -aot ""<curitem>""",,1;
    delete 1, 0, <curitem>;
You can also use 7z.exe instead of 7zG.exe for command prompt styled extraction.

Lare2
Posts: 65
Joined: 18 Sep 2006 08:29

Re: Help With Script Involving 7-Zip.

Post by Lare2 »

That worked. Thanks to both of you for that.

I was trying to get something like this to work but my script was already like five command lines long. Needless to say that it wasn't working. On the other hand people like you come around and achieve the same result with so little code..... :lol:

Thanks again

Post Reply