Copying Files Out of Zipped Folders

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
WonderFerret
Posts: 3
Joined: 26 Jun 2017, 17:46

Copying Files Out of Zipped Folders

26 Jun 2017, 17:54

I am trying to copy files out of zipped folders using FileCopy. Here is a very simple example command:

^g::
FileCopy, C:\Users\User1\Desktop\zippedfolder.zip\sometextfile.txt, C:\Users\User1\Desktop


This command only seems to work with non-zipped folders and I'm not sure why. Any suggestions?
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Copying Files Out of Zipped Folders

27 Jun 2017, 03:24

This command only seems to work with non-zipped folders and I'm not sure why.
If you can show me any indicator that FileCopy is meant to extract files from a zipped archive I owe you a beer. OK, let's see ...

https://autohotkey.com/docs/commands/FileCopy.htm
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Copying Files Out of Zipped Folders

27 Jun 2017, 06:19

- I would look at 7-Zip command line. Best of luck.
- I don't think FileCopy can do this.
- I couldn't find a way to do this via Windows itself, via the command line.
- There might be a Winapi dll function for this?

[I found this link which uses an object method:]
vbscript - Can Windows' built-in ZIP compression be scripted? - Stack Overflow
https://stackoverflow.com/questions/302 ... e-scripted

[EDIT: This link appears to do the same thing in AHK, thanks BoBo, I was just searching for such a script.]
Native Zip and Unzip XP/Vista/7 [AHK_L] - Scripts and Functions - AutoHotkey Community
https://autohotkey.com/board/topic/6070 ... ta7-ahk-l/
Last edited by jeeswg on 27 Jun 2017, 06:39, edited 3 times in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Copying Files Out of Zipped Folders

27 Jun 2017, 06:26

jeeswg wrote:I would look at 7-Zip command line. Best of luck.

There might be a Winapi dll function for this?
Maybe someone is able to cross-check this/bring it back to life: [native-zip-and-unzip] ... and mentioned at the same thread, [ ... a COM option]
Last edited by BoBo on 27 Jun 2017, 08:44, edited 1 time in total.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Copying Files Out of Zipped Folders

27 Jun 2017, 06:36

Well, this worked for me (I created a zip via 7-Zip and extracted it using one of the functions from the link above):

Code: Select all

;Native Zip and Unzip XP/Vista/7 [AHK_L] - Scripts and Functions - AutoHotkey Community
;https://autohotkey.com/board/topic/60706-native-zip-and-unzip-xpvista7-ahk-l/

q:: ;extract files from zip file
vPathZip = %A_Desktop%\MyZip.zip
vDirOutput = %A_Desktop%\MyZip
Unz(vPathZip, vDirOutput)
return

Unz(sZip, sUnz)
{
    fso := ComObjCreate("Scripting.FileSystemObject")
    If Not fso.FolderExists(sUnz)  ;http://www.autohotkey.com/forum/viewtopic.php?p=402574
       fso.CreateFolder(sUnz)
    psh  := ComObjCreate("Shell.Application")
    zippedItems := psh.Namespace( sZip ).items().count
    psh.Namespace( sUnz ).CopyHere( psh.Namespace( sZip ).items, 4|16 )
    Loop {
        sleep 50
        unzippedItems := psh.Namespace( sUnz ).items().count
        ToolTip Unzipping in progress..
        IfEqual,zippedItems,%unzippedItems%
            break
    }
    ToolTip
}
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WonderFerret
Posts: 3
Joined: 26 Jun 2017, 17:46

Re: Copying Files Out of Zipped Folders

27 Jun 2017, 18:01

Thank for the reply, all. But I think I found a suitable work around. In my company, we download reports and a bunch of these text files come within numerous zipped folders. Its very tedious to sort them all and place them in the appropriate folders. I automated the sorting process with autohotkey but could not automate the extraction process. I just assumed since a zipped folder is a type of folder, there would be a filepath to specify the location of its contents and I was just typing the path wrong with FileCopy. Ultimately, I decided to open zip folder, select all files via send ctrl+a, send ctrl+c, make desired folder active, and send ctrl+v. But thanks for the reply everyone!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Ineedhelplz, jaka1, penguinautomator, Spawnova and 279 guests