Announcement

Collapse
No announcement yet.

Empty Folders in Zip File

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Empty Folders in Zip File

    I've observed that empty folders are no longer included in a Zip File that is created by the Windows 10 compression option.

    That's a bummer because I wanted my users to be able to unzip a file and get a specified folder structure, where some folders might be empty.

    However, I've found that 7Zip will include empty folders and that the Windows 10 unzip feature will reproduce the empty folders.

    So when I distribute a zip file, I have to use 7Zip to ensure that empty folders are included. Then, my users can use the built-in Win10 unzip and still get the empty folders that I want them to have.

    I can't depend on 7Zip being available on the user's PC, so I'm glad to find that Win10 will give the results I want.

    I can, of course, always check for the presence of needed folders and create them on the fly as required.



  • #2
    That is just crazy. You know a main operating system folder such as a Temp folder can be empty and if you check for the directory being there and not find it is just so damn stupid of them. Tell you created the folder and it is your folder and Not Microsoft's folder.
    p purvis

    Comment


    • #3
      Hi Paul!
      From what I read, the exclusion of empty folders when compressing is a new "feature". In previous versions of Windows, compression did include the empty folders. I've not read any explanation of why the change was adopted.

      Comment


      • #4
        Gary, Feature! Your starting to sound like Michael.
        p purvis

        Comment


        • #5
          This is kind of timely. I saw today "New Folder"
          nested 5 times deep in a directory meant for word documents. Maybe Microsoft meant to get ride of those folders.
          p purvis

          Comment


          • #6
            Hi Gary

            Perhaps you should make a small installation or initialization program that user must run
            after unzipping the application with the following routine. This routine will create a or several
            folders that are missing.

            Code:
            '==========================================
            ' Create the necessary missing folders for this
            ' system as Microsoft Win10 compression does not create
            ' empty folders
            ' This will form the software activation process
            SUB MakeMyFolders
               LOCAL FolderName AS STRING
               SLEEP(10)
               FolderName = "C:\Myfolder\Tmp1\"
               IF ISFALSE ISFOLDER(FolderName) THEN
                  MKDIR FolderName
               END IF
               SLEEP(10)     
               FolderName = "C:\Myfolder\Tmp2\"
               IF ISFALSE ISFOLDER(FolderName) THEN
                  MKDIR FolderName
               END IF
               SLEEP(10)     
            
            END SUB

            Comment


            • #7
              Howdy, Anne!
              Yep, I do something like that now. I just wanted to avoid that if possible. Another thing I've done is put some kind of dummy file in the "empty" folder - one that won't throw the using app for a loop. I can delete that, or not, at run time if necessary.

              Comment


              • #8
                "garybeenes-emptyfile.txt"
                p purvis

                Comment


                • #9
                  Neat idea, Gary
                  Yup, place in dummy files into these "supposedly empty" folders, this is just for installation purpose.
                  Then on the first run of the main program, delete off these dummy files.

                  Comment


                  • #10
                    I've not tried it but perhaps the secret file could be named "thumbs.db" and have its hidden file attribute set.
                    https://www.BcxBasicCoders.com

                    Comment


                    • #11
                      I did not know that also on my win xp sp3 system, that if I did not unblock a zipped file downloaded and uncompressed the file, all, AND I MEAN ALL, the files and likely the directories too, have file dates as the date and time I unzipped it using the operating system's default zip and unzip.
                      I have been using pkunzip and winzip for years and I just started using the operating system zip(compress) feature.
                      I really do not like what it is doing. If you do not unblock the file in file properties, you can use the copy(using the os drag capabilities) the files over and that will preserve the dates of the files.
                      The only reason I started using the operating system, was because I need to zip up a large number of files and some where not the 8.3 file naming standards that I try to use.
                      p purvis

                      Comment


                      • #12
                        Paul,
                        You might look at streams which does what you want:
                        https://forum.powerbasic.com/forum/u...m-command-line

                        Comment


                        • #13
                          So when I distribute a zip file, I have to use 7Zip to ensure that empty folders are included
                          "Have to?"

                          Five bucks says "CreateDirectory" in your setup program would work just ducky. The same five bucks says changes in operating systems may cause "shortcuts" to doing things the right way to no longer work as desired.

                          Better still, why does the application have to have a folder structure in place? Can't the application itself create folders as needed?

                          My bottom line here is, quit trying to do things 'on the cheap' and these things will no longer affect you.

                          MCM
                          Michael Mattias
                          Tal Systems (retired)
                          Port Washington WI USA
                          [email protected]
                          http://www.talsystems.com

                          Comment


                          • #14
                            Originally posted by Michael Mattias View Post
                            Better still, why does the application have to have a folder structure in place? Can't the application itself create folders as needed?
                            I agree 100%.

                            If my application requires a certain directory structure, I always check for it when the application opens and (re)create if necessary. It's not un-heard of for users to delete directories after installation.

                            Same goes for required files.

                            Comment


                            • #15
                              Originally posted by Anne Wilson View Post
                              Hi Gary

                              Perhaps you should make a small installation or initialization program that user must run
                              after unzipping the application with the following routine. This routine will create a or several
                              folders that are missing.

                              Code:
                              '==========================================
                              ' Create the necessary missing folders for this
                              ' system as Microsoft Win10 compression does not create
                              ' empty folders
                              ' This will form the software activation process
                              SUB MakeMyFolders
                              LOCAL FolderName AS STRING
                              SLEEP(10)
                              FolderName = "C:\Myfolder\Tmp1\"
                              IF ISFALSE ISFOLDER(FolderName) THEN
                              MKDIR FolderName
                              END IF
                              SLEEP(10)
                              FolderName = "C:\Myfolder\Tmp2\"
                              IF ISFALSE ISFOLDER(FolderName) THEN
                              MKDIR FolderName
                              END IF
                              SLEEP(10)
                              
                              END SUB
                              That only works if Myfolder already exists.

                              Comment


                              • #16
                                Paul,
                                Using streams with wzzip/wzunzip should handle any condition

                                http://staff.uob.edu.bh/files/600435...Comp_lab_3.pdf

                                http://staff.uob.edu.bh/files/600435156_files/the_comp_lab_5.pdf

                                Comment


                                • #17
                                  Guys ... you're only mentioning something I already put in the OP ....

                                  I can, of course, always check for the presence of needed folders and create them on the fly as required.

                                  Comment


                                  • #18
                                    Stuart/MCM,

                                    I can imagine several scenarios where I'd like to have the folder in place before my app runs.

                                    For example, my user might want to put some files into a folder that my app was designed to use. If he tries to do that before my app runs, then having the folder there for him is a convenience.

                                    It doesn't have to be a great reason, just a reason.

                                    Comment


                                    • #19
                                      Is Innosetup too much overhead? It can run programs before and after setup (if needed.)

                                      I just downloaded a zip file from this board with an executable within it.
                                      I noticed the exe file within .zip file was not blocked by Windows 10 Pro.

                                      I use Innosetup, but these sound interesting.

                                      > I can't depend on 7Zip being available on the user's PC
                                      7Zip self extractor?

                                      Two versions of WinZip self extractor
                                      http://kb.winzip.com/kb/?View=entry&EntryID=184

                                      This looks interesting.
                                      http://www.peazip.org/self-extracting-archives.html

                                      Comment


                                      • #20
                                        Hi Mike,
                                        I'd forgotten about the 7Zip self extractor option. But, from tests I ran, the Windows built-in unzip recognizes/restores a ZIP file created by 7Zip and will restore the empty folder, even if it won't add it to a compressed file. So there's no need for the user to have 7Zip, only for me to use it.

                                        Comment

                                        Working...
                                        X