Alpha Video Training
Results 1 to 5 of 5

Thread: zip Folder

  1. #1
    "Certified" Alphaholic
    Real Name
    Thomas Patten
    Join Date
    Apr 2000
    Location
    Duluth, MN
    Posts
    1,494

    Default zip Folder

    I need to zip a folder containing up to 50 sub-folders for backup.

    I've been trying file_zip() without success; e.g. file.zip(full_zip_filename,filename + chr(92) + "*.*")

    Ideas?

    Thanks ~ Tom

  2. #2
    "Certified" Alphaholic
    Real Name
    Thomas Patten
    Join Date
    Apr 2000
    Location
    Duluth, MN
    Posts
    1,494

    Default Re: zip Folder

    So the file_zip will ONLY zip FILES not FOLDERS. I need a folder_zip function.

    Ideas?

    ~ Tom

  3. #3
    "Certified" Alphaholic
    Real Name
    Finian Lennon
    Join Date
    Apr 2000
    Location
    Atlanta, GA
    Posts
    1,804

    Default Re: zip Folder

    Tom:

    Try this code and see if it works for you.

    You can't run the file list for the current folder unless you remove any file that might be open from the list. So test it on an external folder where no files are open or in use.

    When I ran this on a relatively small folder it worked fine, but not on a copy of my app folder which has 76,000 files in it (many sub-folders with many files.) The list was always created fine, but the zip creation failed every time.

    Code:
    fmt1 = FILE_FIND_NORMAL
    strt = "d:\aaaa\bbbbbb\ccccccc" +chr(92)
    gfiles = "*.*"
    fmt2 = "PN"
    fname = "D:\temp\flist.txt"
    lst = filefind.get_recurse(strt,gfiles,fmt1,fmt2)
    save_to_file(lst,fname)
    zipfile = "D:\temp\test.zip"
    opts = "D,"
    if file.exists(zipfile) then
    	file.remove(zipfile)
    end if
    res = file.zip(zipfile,lst,Opts,strt)
    if res then
    	msg_txt = "The zip file was created!"
    	else
    		msg_txt = "The zip file not was created!"
    end if
    msgbox("",msg_txt)
    This uses filefind.get_recurse() to create a list of the subfolders and their contents, then processes the list. The zip contents are listed relative to the starting folder.
    Substitute your own folder location into "strt" and your output file name into "zipfile". I save the list only so you can check the list contents.

    I was tring to do this myself a couple of years ago and gave up on the Alpha methods apart from the filefind.get() and filefind.get_recurse(). I ended up creating the list, saving it to a file then creating a batch file on the fly to run with sys_shell_wait() containing a WinRar command line. Works every time.
    Finian

  4. #4
    "Certified" Alphaholic
    Real Name
    Thomas Patten
    Join Date
    Apr 2000
    Location
    Duluth, MN
    Posts
    1,494

    Default Re: zip Folder

    Finian - it worked first time. FANTASTIC!

    Thank you very much. Now I can go to sleep!

    ~ Tom

  5. #5
    "Certified" Alphaholic
    Real Name
    Finian Lennon
    Join Date
    Apr 2000
    Location
    Atlanta, GA
    Posts
    1,804

    Default Re: zip Folder

    Happy to help.

    The file.zip() function appears to have some sort of limitation, either in the number of files or the output file size. I checked the folder that wouldn't zip with that code and it has 200+ folders, 75,000 + files and is approx 12gigs in size. I used my trusty explorer substitute (Total Commander) this morning and it zipped down to about 8gigs. There are thousands of image files, hence the low rate of compression.
    Finian

Similar Threads

  1. TabbedUI How do I expand a tree folder \ branch on folder or text click?
    By LukeS in forum Application Server Version 11 - Web/Browser Applications
    Replies: 8
    Last Post: 09-16-2013, 04:19 PM
  2. *.WebProjects Folder Not Getting Pulled Into Desktop Shadow Folder
    By drjgs200 in forum Alpha Five Version 11 - Desktop Applications
    Replies: 8
    Last Post: 05-17-2013, 06:36 PM
  3. Folder in webroot - Target Folder
    By Atta in forum Application Server Version 11 - Web/Browser Applications
    Replies: 1
    Last Post: 08-16-2012, 02:51 PM
  4. Is it OK to delete the files in the Cached_Data folder in the project folder?
    By kingcarol in forum Application Server Version 11 - Web/Browser Applications
    Replies: 0
    Last Post: 10-24-2011, 12:06 PM
  5. Function for select folder using windows get folder dialog?
    By jjfcpa in forum Alpha Five Version 9 - Desktop Applications
    Replies: 1
    Last Post: 08-12-2008, 05:49 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •