PDA

View Full Version : ZipsToFolders - function/Project


Intrigued
05-29-2005, 01:01 PM
--[[

This is a function that will create a folder on the system's Desktop (ZipsToFolders)...
and then will unzip the contents of all .zip files from a (we'll call it) "master folder"...
that is chosen by the end-user. Here's the neat part. This function creates folders exactly...
matching each of the original .zip files' names and then puts all of them into the ZipsToFolders folder!

I want to thank forum user Bruce for his excellent and free offering(s) of Masks. His offering...
inspired this function.

Lastly, remember, you can play with this function, adjust it to your liking. How about adding...
in the ability to create a custom named folder to replace the default folder (defaults to: ZipsToFolders) of the end-users choosing?

]]
function ZipsToFolders()
strTargetGetFolder = Dialog.FolderBrowse("Choose a Folder containing .zip file(s)...", _DesktopFolder)
if strTargetGetFolder ~= "CANCEL" and strTargetGetFolder ~= "" then
tblFiles = File.Find(strTargetGetFolder, "*.zip", true, true, nil, nil)
if tblFiles ~= nil then
Folder.Create(_DesktopFolder.."\\".."ZipsToFolders")

StatusDlg.Show(true, false)
StatusDlg.SetAutoSize(false)

for index, path in tblFiles do
tblPath = String.SplitPath(path)
Folder.Create(_DesktopFolder.."\\ZipsToFolders\\"..tblPath.Filename)
Zip.Extract(path, {"*.*"}, _DesktopFolder.."\\ZipsToFolders\\"..tblPath.Filename, true, true, "", ZIP_OVERWRITE_NEVER, nil)
end

StatusDlg.Hide()

else
Dialog.TimedMessage("Notice!", "There were no files in this folder, aborting...", "3000", MB_ICONEXCLAMATION)
Application.ExitScript()
end

else
Application.ExitScript()
end
end

-- Call the function (aka. use it)
ZipsToFolders()

Intrigued
05-29-2005, 01:22 PM
Note: It could also use a little more bullet-proofing.

:p

yosik
05-29-2005, 02:45 PM
Good one Intrigued.
It will come very handy.
Thanks a lot for that. :yes
Yossi

Intrigued
05-31-2005, 12:37 PM
Thanks Yosik.

:yes

Bruce
05-31-2005, 06:57 PM
Intrigued-
Thanks for the kudos! :lol

Intrigued
05-31-2005, 08:14 PM
Intrigued-
Thanks for the kudos! :lol

What goes around comes around!

(hey, that can be a good th'ang!)

:D