Indigo Rose Software
  #1  
Old 09-25-2008
llabate llabate is offline
Forum Member
 
Join Date: Oct 2007
Location: Tucson, AZ
Posts: 3
Grin Zip.Extract to recreate folder structure?

I have read other posts regarding this, but I haven't been able to find a way around this problem. I want to use Zip.Extract to extract and recreate the subfolders just as they were in the folder that they were backed up from (i.e. for potential rollback after an upgrade). I am using the following code to zip up the files noted below it:

ZipBackupFile = "C:\\ZipFolderTest";
BackupFolder = "C:\\topfolder";
tblFilesToBackup = {};
tblFilesToBackup = File.Find(BackupFolder,"*.*",true,true,nil);
Zip.Add(ZipBackupFile,tblFilesToBackup,true,"",tru e,0,nil,true);

then later:
Zip.Extract("C:\\ZipFolderTest.zip",{"*.*"},"C:\\e xtractfolder",true,true,"",ZIP_OVERWRITE_ALWAYS,ni l);

files to be zipped:
c:\topfolder\subfolder1\test1.txt
c:\topfolder\subfolder1\test2.txt
c:\topfolder\subfolder2\test3.txt
c:\topfolder\subfolder2\test4.txt

desired extraction structure:
c:\extractfolder\subfolder1\test1.txt
c:\extractfolder\subfolder1\test2.txt
c:\extractfolder\subfolder2\test3.txt
c:\extractfolder\subfolder2\test4.txt

What I actually get with Zip.Extract (depending on how "include folders" and "recurse" are set) is either:

c:\extractfolder\test1.txt
c:\extractfolder\test2.txt
c:\extractfolder\test3.txt
c:\extractfolder\test4.txt

- or - the above plus the two empy folders, subfolder1 and subfolder2. I can't seem to extract the files ~into~ the subfolders.

Help! Thanks in advance for any suggestions.
Reply With Quote
  #2  
Old 09-25-2008
Ulrich's Avatar
Ulrich Ulrich is offline
Indigo Rose Staff Member
 
Join Date: Apr 2005
Location: Sao Paulo, Brazil
Posts: 823
Here is an example to compress a folder:
Code:
-- define source folder to compress
FolderName = Dialog.FolderBrowse("Select the folder to compress", _TempFolder)
-- define destination archive
ZipBackupFile = _TempFolder .. "\\IR_ZipActions.zip";
-- include everything in the source folder
tblFilesToBackup = { FolderName .. "\\*.*"}
-- perform the file compression (without callback, so wait for confirmation/error dialog)
Zip.Add(ZipBackupFile, tblFilesToBackup, true, "", 5, 0, true);
error = Application.GetLastError();
if (error ~= 0) then
    Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
else
    Dialog.Message("Success", "Folder " .. FolderName .. " was successfully compressed to " .. _TempFolder .. "\\IR_ZipActions.zip\r\n" .."Please examine the file (with WinZip or something else) before proceeding." , MB_OK, MB_ICONINFORMATION);
end
And here I decompress it:
Code:
-- try to uncompress the file IR_ZipActions.zip in your temporary folder
if (File.Find(_TempFolder, "IR_ZipActions.zip") == nil) then
    Dialog.Message("Error", "The expected zip file was not found.\r\nDid you compress any folder first?", MB_OK, MB_ICONEXCLAMATION);
else
    -- perform the uncompression (again withou callback, so wait for outcome)
    Zip.Extract(_TempFolder .. "\\IR_ZipActions.zip", {"*.*"}, _TempFolder .. "\\Extractfolder", true, true, "", ZIP_OVERWRITE_ALWAYS);
    error = Application.GetLastError();
    if (error ~= 0) then
        Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
    else
        Dialog.Message("Success", "The files contained in " .. _TempFolder .. "\\IR_ZipActions.zip were recursively extracted to " .. _TempFolder .. "\\ExtractFolder\\\r\nCheck the folder contents now.", MB_OK, MB_ICONINFORMATION);
    end
end
Ulrich

Last edited by Ulrich; 03-06-2009 at 07:13 AM.
Reply With Quote
  #3  
Old 10-02-2008
llabate llabate is offline
Forum Member
 
Join Date: Oct 2007
Location: Tucson, AZ
Posts: 3
Thanks!

Thanks so much, Ulrich. In the end they decided to go with another backup method, but I will save this code for future reference, as I know it will come up again
Reply With Quote
  #4  
Old 12-10-2008
kk250040's Avatar
kk250040 kk250040 is offline
Forum Member
 
Join Date: Feb 2008
Posts: 81
Grin attempt to index global 'Zip' (a nill value)

Are Zip.Add and Zip.Extract part of Setup factory?? I am using SF7 version.
I am getting errors saying :

Quote:
attempt to index global 'Zip' (a nill value)
I did not find any help information in the help stuff too, does that mean that the command itslef is not available in SF7?

Can anyone comment on this with any useful information to zip and extract files from SF, or if I have any command line commands for windows to zip files?
Reply With Quote
  #5  
Old 12-10-2008
Ulrich's Avatar
Ulrich Ulrich is offline
Indigo Rose Staff Member
 
Join Date: Apr 2005
Location: Sao Paulo, Brazil
Posts: 823
Quote:
Originally Posted by kk250040 View Post
Are Zip.Add and Zip.Extract part of Setup factory?? I am using SF7 version.
Yes, it is. But maybe you haven't enabled it in your setup. Check in the menu of SUF70, under Resources > Plugins, and see if the Zip option is checked.

Ulrich
__________________
Reply With Quote
  #6  
Old 12-10-2008
kk250040's Avatar
kk250040 kk250040 is offline
Forum Member
 
Join Date: Feb 2008
Posts: 81
Its Working, Thanks

Working now,
My Zip plugin was unchecked as you said
ThankYou!
Reply With Quote
  #7  
Old 12-11-2008
kk250040's Avatar
kk250040 kk250040 is offline
Forum Member
 
Join Date: Feb 2008
Posts: 81
Please provide the help avaialble for Zip.Add() from the help files

This is all okay, but I still do not have the Zip.Add or related stuff in the HelpFiles. Can someone post the syntax and its support details from their respective help files if they have it. I am trying to get a Progress bar while zipping my contents for backup and I dont have the help file for the Zip.Add to refer. The samples might work, but I want to know in and out of the command before I use it in my setups.

Please paste it here, or guide me where I can get it, or why I do not have it in the referring manuals?


ThankYou!
Reply With Quote
  #8  
Old 12-11-2008
Ulrich's Avatar
Ulrich Ulrich is offline
Indigo Rose Staff Member
 
Join Date: Apr 2005
Location: Sao Paulo, Brazil
Posts: 823
Quote:
Originally Posted by kk250040 View Post
This is all okay, but I still do not have the Zip.Add or related stuff in the HelpFiles. Can someone post the syntax and its support details from their respective help files if they have it.
Hello,

plugins are extensions to the product, and their help files are separate from the product's own docs, provided by the writer of the plugin - not necessarily Indigo Rose.

For most available plugins, you can see the shipped help file this way:
In the menu, go to Resources > Plugins, select the plugin, click About Plugin, then click Plugin Help. This should open the documentation, which can be a HTML file, PDF doc, etc.

Ulrich
__________________
Reply With Quote
  #9  
Old 12-11-2008
kk250040's Avatar
kk250040 kk250040 is offline
Forum Member
 
Join Date: Feb 2008
Posts: 81
Thats exactly what I needed

Thank You Ulrich
Reply With Quote
Reply

Tags
zip.extract

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing resource folder structure dnandor AutoPlay Media Studio 6.0 2 07-20-2007 11:42 AM
IF else statement synistics AutoPlay Media Studio 6.0 3 04-21-2007 01:33 PM
cookies goukilord10 AutoPlay Media Studio 5.0 6 05-20-2005 05:08 PM
INFO: The Explore Button on the Distribution Folder Dialog Support AutoPlay Media Studio 4.0 Examples 0 10-11-2002 01:06 PM


All times are GMT -6. The time now is 04:49 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright © 2000 - 2009 Indigo Rose Corporation. All rights reserved.
Indigo Rose Software