OT ish

S

Seymore4Head

I have a folder for extracting temporary files.
Is it possible to have a batch file that you can drag a filename to
and have it automatically extract the file to a temporary folder?
 
P

Paul

Seymore4Head said:
I have a folder for extracting temporary files.
Is it possible to have a batch file that you can drag a filename to
and have it automatically extract the file to a temporary folder?

This is overkill, and uses .NET, so wouldn't be my first
choice. This idea uses a "watched folder".

http://www.codeproject.com/Articles/246365/Automatic-Zip-Extractor

*******

An easier solution would be to install 7-ZIP, right-click the file
and extract using the 7Z context menu options.

Even the 9.30 version works perfectly fine.

http://www.7-zip.org/

Paul
 
M

Mayayana

|I have a folder for extracting temporary files.
| Is it possible to have a batch file that you can drag a filename to
| and have it automatically extract the file to a temporary folder?
|
Your question doesn't make sense. Do you mean
that you want to drag a ZIP file to a batch file
and have the contents extracted?

The following will work. Drop any ZIP file on
it and the contents will be extracted to a folder
of the same name, in the same location.
Example: C:\Folder1\pictures2.zip will be extracted
to a folder C:\Folder1\pictures2.

Notes:
* You must first install 7-Zip.

* The path to 7-Zip is assumed to be in Program Files.
Edit that path if necessary.

* You may have problems using this on
Vista/7 because the restrictions there make drag-drop
problematic for scripts. I don't remember offhand whether
it's possible to make it work by turning off UAC. The other
option would be to use a prompt that requires you to type
the path of the ZIP file, which would be a lot more work.

* This is a VBScript file. When it's saved it should end with
.vbs, not .txt.

'-- paste the following into Notepad and save as Extractor.vbs ----

Dim Arg, Qt, sCommand, SH, FSO, Ret, FolData, Pt1, sFil

On Error Resume Next
Set FSO = CreateObject("Scripting.FileSystemObject")
Arg = WScript.Arguments(0)
If FSO.FileExists(Arg) = False Then MsgBox "Drop a ZIP file onto the
script.": DropIt
If UCase(Right(Arg, 4)) <> ".ZIP" Then MsgBox "Drop a ZIP file onto the
script.": DropIt

Qt = Chr(34)
Pt1 = InStrRev(Arg, "/")
FolData = Left(Arg, Pt1)
sFil = Right(Arg, (len(Arg) - Pt1)): sFil = Left(sFil, (len(sFil) - 4))
FolData = FolData & sFil

If FSO.FolderExists(FolData) = False Then FSO.CreateFolder FolData
sCommand = Qt & "C:\Program Files\7-Zip\7z.exe" & Qt
Set SH = CreateObject("WScript.Shell")
Ret = SH.Run(sCommand & " e " & Qt & Arg & Qt & " -o" & Qt & FolData & Qt,
, True)

DropIt
Sub Dropit()
Set FSO = Nothing
Set SH = Nothing
WScript.Quit
End Sub

'---- end script ------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top