5 Replies Latest reply on Dec 10, 2009 10:27 PM by Steveorevo

    unzip on mac (and pc)

    Tols (UK)

      well i looked for something on this subject but found no answer specific to director (thought i'm sure it's there somewhere), so I thought I'd work it out rather than ask someone (I've asked enough questions recently...!) and I'd thought i'd share it.


      If someone spots a bug or room for improvement, please feel free to let me know. I have only tested on Mac OS 10.5 (Dir11.5) but I think this will work from at least 10.3.9 (as my older mac seems to have unzip in its shell). Also I haven't tested on more than a few files.


      you will need valentin schmidt's 2009 (v05) shell.xtra for Dir 11, which I can't for the life of me remember where I found. So if anyone wants to reply with that link I'm sure that would be useful for many. Google let me down on that one.



      on pc

      eg. bzUnZip(filename, extractfolder, "add", true, false, false ) --windows is easy cause there's an xtra though I can't find the documentation for bzunzip -


      on mac.


      on unzip filename, exdir, updatetype, protecttext, keepfolders


        --this is for mac only

        --exdir is where you want zip to be extracted to, leave void and it will extract next to zip

        --updatetype - i've only allowed for "update"

        --protecttext - apparently this will extract text files (if there are any) with the correct line endings for the platform

        --keepfolders - boolean - true means the zip's folder structure is kept, false means you get a bundle of folderless files.

        --for more info on the parameters and for putting your own ones in look at http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man1/unzip. 1.html

      -- yes, a few custom handlers are needed. if you are doing this then i'm sure you have your own for fileexists(), folderexists(), and folderdelete() and if not you'll prob want Buddy Api or FileXtra4 (pre dir11) for those.




        if voidp(exdir)=0 then


        end if


        if fileexists(filename)=0 then return "File doesn't exist"  --custom handler required

        params=" -"

        if updatetype="update" then

          put "u" after params

        end if

        if protecttext then

          put "a" after params

        end if

        if keepfolders.value=0 then

          put "j" after params

        end if


        if voidp(exdir)=0 then

          ret= shell_cmd("unzip" & params & " '"&posixPath&"' -d '"&posixdir&"'")


          ret= shell_cmd("unzip '" & params & " '"&posixPath&"'")

        end if


      --for some reason this annoying __MACOSX folder pops up sometimes in the extractdir.. tut - so I choose to delete it. feel free not to!


        if voidp(exdir) =0 then

          if folderexists(plat(exdir & ":__MACOSX")) then  --custom handler required

            folderdelete(plat(exdir & ":__MACOSX"),1)    --custom handler required, the 1 is for deleting subfolders cause there will be at least one.

          end if

        end if


        if ret contains "inflating" then --inflating is an indication its done something.

          return 1


          return ret --if it doesn't inflate I thought I would return the output itself in case its handy

        end if





        • 1. Re: unzip on mac (and pc)
          Sean_Wilson Adobe Community Professional

          Valentin's Shell xtra can be found here


          bzUnZip() is a function of the budunzip xtra that seems to have been removed from the Buddy API website - if someone needs it they should mail Gary.


          On Windows (I'm not sure about the Mac) there is the "native" (free, ships with the IDE) UnzipXtra.

          put interface(xtra "UnzipXtra")
           -- "xtra UnzipXtra -- version 11.5.0.r593
          new object me -- create a new child instance
          UnzipFiles object me, string zipFileName, string destinationDirectory -- unzip a file.
          • 2. Re: unzip on mac (and pc)
            Tols (UK) Level 1

            ah yes, that no-nonsense directory listing looks familiar - thanks.


            and yes unzipxtra does seem to come with the mac as I get the same 

            result from that interface command


            so i've wasted my time in posting all that - somewhat


            By the way, are these included xtras listed anywhere? -


            thanks very much

            • 3. Re: unzip on mac (and pc)
              Sean_Wilson Adobe Community Professional
              By the way, are these included xtras listed anywhere?

              For scripting xtras, you can get a list by executing 'showXLib' in your message window - this will show some of the built-in xtras that are poorly documented (like the UiHelper xtra). It will also give you the name of the xtra to query with interface() to learn more about its implemented methods. However, it will also show any 3rd-party scripting xtras you might have installed so isn't quite the listing you were looking for.


              Asset xtras can be obtained from _player.mediaXtraList - but the list returned isn't as readily readable as with the showXLib command.

              • 4. Re: unzip on mac (and pc)
                Tols (UK) Level 1

                That's great - very useful.

                I've just converted it all into a kind of documentation, which is a bit easier to browse.

                • 5. Re: unzip on mac (and pc)
                  Steveorevo Level 1

                  When I create a Mac.app in D11 it tells me that the Unzip Xtra can't be found. Is it for Windows Only or ships with D11.5 (which I don't have).