View Full Version : Action Commands-WHILE File search and UNZIP
nancyp
11-30-2001, 02:14 PM
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 goodfile.zip)
Create a folder called goodfile if it does not exist.
Extract contents of goodfile.zip to this folder called: goodfile
delete goodfile.zip
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.
Hi,
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.
mark.
[This message has been edited by Mark (edited 11-30-2001).]
[This message has been edited by Mark (edited 11-30-2001).]
nancyp
12-03-2001, 04:28 PM
Thank you for the help. I think I almost have it but it is not quite right and I need some help.
%AppDir%=d:\md
The zips are in %AppDir%\zips
Sample name: mosaddr.zip
Sample name: mosmenNT.zip
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
%FolderName%.
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?
Nancy
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.