No announcement yet.

Action Commands-WHILE File search and UNZIP

This topic is closed.
  • Filter
  • Time
  • Show
Clear All
new posts

  • Action Commands-WHILE File search and UNZIP

    I have a folder that contains a large number of .zip files.

    Can I build an action loop with WHILE or IF that will do the following:

    Find a zip file (example: called
    Create a folder called goodfile if it does not exist.
    Extract contents of to this folder called: goodfile

    Now look for the next file with a .zip extention and repeat this until all the .zip files have been extracted.

    Thanks to anyone for some help on this.

    Currently the zip file does not have the recursive folder name but I could change that if necessary.

  • #2
    Re: Action Commands-WHILE File search and UNZIP


    Yes this is possible, what you would do is use a "Search For Files" action. Now, a "Search For Files" action will return a comma-delimited list of all items that match your search query.

    You would then parse this list for the number of entries; the number of entries will control how many times you loop. Then parse through the search result, stripping one path off at a time. Now with our string actions you will be able to drop the .ZIP extension and the rest of the path. Then use an "UnZip Files" action to unzip the files.

    Here is some pseudo-code:

    Search For File (*.ZIP)
    Count Delimited Strings (Store in %NumberOfDelimitedStrings%)
    Assign Value (%Counter% = 0)
    While (%Counter% < %NumberOfDelimitedStrings%)
       Get Delimited String (At %Counter%, Store in: %DelString%)
       Find String (Find “\”, In %DelString%, Search: Backward, Store in: %SlashPos%)
       RightString (Starting at: %SlashPos%, In: %DelString%, Store in: %FolderName%)
       Length of String (In: %FolderName%, Store In: %Length%)
       Assign Value (%Length% = %Length% - 3)
       LeftString (Starting at: %Length, In: %FolderName%, Store in: %FolderName%)
       UnZip Files (Zip File: %DelString%, UnZip to: %AppDir%\%FolderName%)
       Assign Value (%Counter% = %Counter% + 1)
    End While
    That is a very brief description of what you need to do, try it out. If you have troubles, post how far you got and I will try to point you in the right direction.


    [This message has been edited by Mark (edited 11-30-2001).]

    [This message has been edited by Mark (edited 11-30-2001).]
    MSI Factory The Next Generation Intelligent Setup Builder


    • #3
      Re: Action Commands-WHILE File search and UNZIP

      Thank you for the help. I think I almost have it but it is not quite right and I need some help.


      The zips are in %AppDir%\zips
      Sample name:
      Sample name:

      I understood your pseudo-code.

      I am pretty close. It is extracting all the files into %AppDir%\filepro

      It should be extracting into %AppDir%\filepro

      The unzip fails on the first %FolderName% that does not exist and it should create.

      How can I send you the actions so you can see it? I am unable to paste to this board from Setup Factory actions. I did export the code but of course attachments are not allowed.

      Thank you for steering me in the right direction.

      BTW - Is there a verbose or debug mode that would step thru the action, showing the variables or condition test results?