Sign in to follow this  
Followers 0
kaotkbliss

Extract single files from a zip using 7zip udf

8 posts in this topic

I get .7z archives daily and I've written a program to extract the contents and merge all the pdfs inside.

Well, now they want me to break up the contents into groups of 500 pdfs (sometimes there are a couple thousand or more)

And I figured the easiest way to do this was to put the extraction in a loop unzipping 1 file at a time and have a counter that when it hits 500, change directories.

The problem is, in the UDF I only see 2 functions that appear to just extract everything unless I'm misunderstanding the options for those functions.


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites



Or install the pdfs into directories that are maxed out at 500 files per.  That seems, to me at least, the cleanest method.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

I don't follow :( It seems like you are saying put a limit on how many files can go into the folder but I have no idea how to do that and the folder isn't created until 7zip starts extracting the pdfs from the zip.

I would also think that if I managed to put a limit on the folder, 7zip would just keep going through it's process into the same folder, even though no new files were being added until it reaches end of archive.

Here's what I'm trying to write out

If $zipinzip = "y" Then
    $pdfcount = _7ZipGetFileCount($7zipname)
    $group = 1
    $grfolder = 1
    If $pdfcount > 500 Then
        $ziplist = _7ZipGetFilesList(0, $7zipname)
        For $count = 1 To UBound($ziplist) -1
            $group += 1
            If $group > 500 Then
                $group = 1
                $grfolder += 1
            EndIf   
            ;extract file here
            
        Next
    Else    
    _7ZIPExtractEx(0, $zip, $zippath & "\")
    _7ZIPExtractEx(0, $zippath & "\" & $7zipname, $zippath & "\" & StringTrimRight($7zipname, 3))
    EndIf
    $var = $zippath & "\" & StringTrimRight($7zipname, 3) & "\"

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

Sorry, I index my data within directories then archive them.

My indexes act as sort of a database for me without having to create an actual database.

I thought you programatically put the data into 7z archive and could create directories for them 500 max, that way the extraction would be much faster.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

No, unfortunately we receive the zips from another company who are supposed to archive them in groups of no more than 500 but they aren't :(


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

Since there doesn't seem to be a solution, I've rewritten the code to  extract the files, then "count" how many files are in the new folder.

If it's over 500, then use the FileMove() function to re-arrange the layout and add the new folder paths to an array for merging the pdfs inside each of those folders. Haven't tested yet, but it should work.


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

Have you checked out the exe version of 7zip and the available command-line arguments?

Perhaps that UDF you are using is incomplete?

I just use @ComSpec with the exe.


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

I don't have 7zip installed and don't plan on it. Eventually, my boss' goal is for me to pass this on to the printing guys so all they have to do is basically click a button and they are done, all within autoit.

I'm still a long ways off from that as I need to overcome the sftp issue next.


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0