PhoeniX
(Fresh Scripter)
2001-12-04 01:42 AM
Automaticaly Archive each directory to a individual zip.

Greetings all.

I'm looking for a method to archive many directories that contain sub dirs. To many zip archives using each primary directories name.

Les
(KiX Master)
2001-12-04 02:55 AM
Re: Automaticaly Archive each directory to a individual zip.

Not sure I understand...

Assumptions:
Folder contains files and other folders.
You want to zip up files in folders but not the folders within folders.
You want the zip name to match the folder name.
You have access rights to all files and folders.

Questions:
Is this right?
Do you have nested folders?
Where do the zips go?
What about duplicate names?
What zip product do you intend to use and does is support a Command Line Interface or scripting?
Is there really a Santa Claus?

PhoeniX
(Fresh Scripter)
2001-12-04 03:32 AM
Re: Automaticaly Archive each directory to a individual zip.

LLigetfa,

Thank you for a responce, I'll try make it more clear.

I have a directory structure that holds clients information. Each client has a directory that is named ((file No.) - (client name)) within each client dir are subdirs containing more info.

I need to pkzip each Client Dir (& sub dirs)
as individual client zip archives, using the primary directory name as the archive name.
eg. ((file No.) - (client name)).zip

WinZip has this function but one file at a time, when you click the RMB on the directory you can select "Add To..." it uses the "directory or file name".zip
I would like to automate the process, as I have 7000 to do.


Ta, Phoe.

NTDOCAdministrator
(KiX Master)
2001-12-04 05:17 AM
Re: Automaticaly Archive each directory to a individual zip.

Hello PhoeniX,

Please see this post for a batch file method that can be altered. http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=2&t=002591


I would get a copy of the Command Line add-on for WinZip and use that.

You can then choose any files you want and do all from the command line.

Hopefully this is enough information to get you going.

Please post an update on your progress.

[ 04 December 2001: Message edited by: NTDOC ]

Les
(KiX Master)
2001-12-04 05:55 AM
Re: Automaticaly Archive each directory to a individual zip.

OK, here's some KiX code to enumerate the folder names from the base dir. Since Dir() will also return the two folders '.' and '..', provision has been made. Also, I check to make sure they are folders with GetFileAttr(), ignoring files at that level. All you have left to do is to replace the line "? $basedir+"\"+$name" with whatever your zip utility uses for the CLI.


code:

break on

$basedir = "C:\Program Files"
$Name = Dir("$basedir")
While $Name <> "" and @ERROR = 0
If ($Name <> ".") And ($Name <> "..") And (GetFileAttr($basedir+"\"+$name) & 16)
? $basedir+"\"+$name
EndIf
$Name = Dir() ; retrieve next file
Loop

get $


[ 04 December 2001: Message edited by: LLigetfa ]

NTDOCAdministrator
(KiX Master)
2001-12-04 10:38 AM
Re: Automaticaly Archive each directory to a individual zip.

There you go... Les is more of a KiX purist then I.

Les
(KiX Master)
2001-12-04 03:53 PM
Re: Automaticaly Archive each directory to a individual zip.

EH DOC,
How's it going? Are you weaning yourself off of KiX, or has that move to WSH died?


MCA
(KiX Supporter)
2001-12-05 03:48 AM
Re: Automaticaly Archive each directory to a individual zip.

Dear,

We have made some modification to LLigetfa example.
We are using the command line version of PKZIP.
Also we are using "-ex" (best compression), "-r" (included also subdirectories)
and "-p" (included also pathnames).

code:

break on
$pkzip_mode="add" ; "move"
;
$basedir="c:\windows"
$filename=Dir("$basedir")
WHILE ($filename <> "") AND (@error = 0)
IF ($filename <> ".") AND ($filename <> "..") AND (GetFileAttr($basedir+"\"+$filename) & 16)
; ? $basedir+"\"+$filename
GOSUB create_zip
ENDIF
$filename=Dir()
LOOP
EXIT
:create_zip
IF ($pkzip_mode = "add")
$cmd=" pkzip -a -ex -r -p "
ELSE
$cmd=" pkzip -m -ex -r -p "
ENDIF
$cmd=$cmd+' "$basedir'+'\'+LTRIM(RTRIM($filename))+'.zip" "$basedir'+'\'+'$filename'+'\*.*" '
; SHELL '%comspec% /c $cmd' ; <++++++++++
? $cmd
RETURN


An output example can be:
code:

pkzip -a -ex -r -p "c:\windows\INF.zip" "c:\windows\INF\*.*"
pkzip -a -ex -r -p "c:\windows\SYSTEM.zip" "c:\windows\SYSTEM\*.*"
pkzip -a -ex -r -p "c:\windows\COMMAND.zip" "c:\windows\COMMAND\*.*"
pkzip -a -ex -r -p "c:\windows\HELP.zip" "c:\windows\HELP\*.*"
pkzip -a -ex -r -p "c:\windows\FONTS.zip" "c:\windows\FONTS\*.*"
pkzip -a -ex -r -p "c:\windows\SendTo.zip" "c:\windows\SendTo\*.*"
pkzip -a -ex -r -p "c:\windows\WANGSAMP.zip" "c:\windows\WANGSAMP\*.*"
pkzip -a -ex -r -p "c:\windows\DESKTOP.zip" "c:\windows\DESKTOP\*.*"
pkzip -a -ex -r -p "c:\windows\JAVA.zip" "c:\windows\JAVA\*.*"
pkzip -a -ex -r -p "c:\windows\CONFIG.zip" "c:\windows\CONFIG\*.*"
pkzip -a -ex -r -p "c:\windows\MEDIA.zip" "c:\windows\MEDIA\*.*"
pkzip -a -ex -r -p "c:\windows\CURSORS.zip" "c:\windows\CURSORS\*.*"
pkzip -a -ex -r -p "c:\windows\TEMP.zip" "c:\windows\TEMP\*.*"
pkzip -a -ex -r -p "c:\windows\SYSBCKUP.zip" "c:\windows\SYSBCKUP\*.*"
pkzip -a -ex -r -p "c:\windows\spool.zip" "c:\windows\spool\*.*"
pkzip -a -ex -r -p "c:\windows\History.zip" "c:\windows\History\*.*"
pkzip -a -ex -r -p "c:\windows\Temporary Internet Files.zip" "c:\windows\Temporary Internet Files\*.*"

We have comment the SHELL call to prevent an unexpected result during
a test run. Please modify it and remove ";" symbol.
greetings.

PhoeniX
(Fresh Scripter)
2001-12-10 08:13 AM
Re: Automaticaly Archive each directory to a individual zip.

LLigetfa, MCA & NTDOC,

I'm very impressed at the responces, I did try out the examples but I'm unable to get MCA's version to run. It will not pass the while loop to process the :create_zip.
I understand a majority of the code, but this isat the end of my kix experiance.
(Sorta why I needed to post the question )

Would any of you be kind enough to help me diagnose it.

(idles..... - is there any #KIX on IRC anymore?)

Thank you all,

PhoeniX

NTDOCAdministrator
(KiX Master)
2001-12-10 10:50 AM
Re: Automaticaly Archive each directory to a individual zip.

Hello PhoeniX,

Please get and install the WinZip command line add-on assuming you already have WinZip v8.0 already installed.

WinZip Command Line Support Add-On Version 1.0 http://www.winzip.com/other.htm http://www.winzip.com/wzcline.htm http://www.winzip.com/getsitec.cgi

Then change this batch file to your folder locations.


code:
for /f "Tokens=*" %%i in ('dir /B D:\users') do c:\progra~1\winzip\wzzip.exe -rP D:\users\%%i.zip D:\users\%%i\*.*

HTH...

If you want or need a PURE KiXtart solution I'm sure Les or MCA can help you out further.

MCA
(KiX Supporter)
2001-12-11 05:33 AM
Re: Automaticaly Archive each directory to a individual zip.

Dear,

First a remark: we send you by email both shareware programs PKZIP & PKUNZIP.

Secondly, some questions:
- are you using this script in another script?
- did you also remove the ";" symbol in the line ; ? $basedir+"\"+$filename
to see which directories were found and will be ZIPped?
- can you put the output of running our script on the board?
greetings.

NTDOCAdministrator
(KiX Master)
2001-12-11 10:48 AM
Re: Automaticaly Archive each directory to a individual zip.

Dear Phoenix, Les, and MCA

I have tested the modified code from MCA which was an adaption of the code by Les and it does work as written by MCA.

NOTES
1.
I'm not sure if PKZIP command line addon supports long file names or not as I have not downloaded it and tested it. The older PKZIP DID NOT support Long File Names.
The WinZip 8 Commnad Line addon does support long file names.
2.
My own personal preference would be to use -rP which would include the "complete" path of where the zip file came from.
3.
You MUST add the program wzzip to your PATH before running. It might be possible to add a direct call to wzzip via further modifications of the script, but easier to just add it to the PATH.

Minor modifications and confirmation that the code does run with KiXtart 2001 and WinZip Command Line Support Add-On 1.0 which requires WinZip v8.0

code:

break on
$pkzip_mode="add" ; "move"
;
$basedir="d:\users"
$filename=Dir("$basedir")
WHILE ($filename <> "") AND (@error = 0)
IF ($filename <> ".") AND ($filename <> "..") AND (GetFileAttr($basedir+"\"+$filename) & 16)
; ? $basedir+"\"+$filename
GOSUB create_zip
ENDIF
$filename=Dir()
LOOP
EXIT
:create_zip
IF ($pkzip_mode = "add")
$cmd=" wzzip -a -ex -rP "
ELSE
$cmd=" wzzip -m -ex -rP "
ENDIF
$cmd=$cmd+' "$basedir'+'\'+LTRIM(RTRIM($filename))+'.zip" "$basedir'+'\'+'$filename'+'\*.*" '
SHELL '%comspec% /c $cmd' ; <++++++++++
;? $cmd
RETURN

That said, both the Script and Batch file perform as intended.

PhoeniX
(Fresh Scripter)
2001-12-12 03:20 AM
Re: Automaticaly Archive each directory to a individual zip.

LLigetfa, MCA & NTDOC,

I have set up the script and checked that
the zip software is pathed. I have removed the semicolon from $basedir+"\"+$filename.
(MCA)

The variables that I changed do work, but it doesn't display me the list of directories that would be zipped. I've taken NTDOCs' suggestions and installed winzip cmdline addons - wzzip (which is pathed)

When I run debug, the script just goes though the code to Exit and finishes. Which shows there is something the While that is not functioning.

Could someone also explain directory enumeration as well........?

PhoeniX

NTDOCAdministrator
(KiX Master)
2001-12-12 10:55 AM
Re: Automaticaly Archive each directory to a individual zip.

Phoenix,

Please post "YOUR" code so that we can see exactly what is going on. If you have your folders setup like my modified sample from MCA, it should run fine. It will not "show" you, it will create the zip files. Please read the help file for the command line add-on for the switches and their meanings.

Don't mix Mine, Les, and MCA's code as it may be causing problems unless you understand what is going on.

Waiting to here back from you with the posting of your actual code used. Maybe you have something odd going on that we can not see just by descriptions of the problem.

The Directory enumeration simply means that it will read through all the folders listed and place them in a variable that is used to perform commands against.

D:\USERS
\DAVE
\BILL
\STEVE

Enumeration would read them one by one and allow looping to perform commands on each one.

Oh! and by the way... This is my 700th post Hope to post many more...

[ 12 December 2001: Message edited by: NTDOC ]

MCA
(KiX Supporter)
2001-12-12 10:23 PM
Re: Automaticaly Archive each directory to a individual zip.

Dear,

Indeed the PKZIP/PKUNZIP doesn't support long filenames. We forget it,
but you can replace the command by another tool which support long names.
Greetings.

MCA
(KiX Supporter)
2001-12-13 04:08 AM
Re: Automaticaly Archive each directory to a individual zip.

Dear NTDOC,

We hope indeed you will post many more.
How is your WSH introduction going on, or has your management changed
their point of view?
greetings.

PhoeniX
(Fresh Scripter)
2001-12-13 04:40 AM
Re: Automaticaly Archive each directory to a individual zip.

Hey all,

well I've produced this, I'm sorry if I've butchered some of your work. Its the only way I'm going to learn the more difficult stuff.
(hope this inserts correctly)

code:
  
break on
?
;
$basedir="c:\kix\springwood\File Archive 2001\*.*"
$filename=Dir($basedir)

WHILE ($filename <> "") AND (@error = 0)
IF ($filename <> ".") AND ($filename <> "..") AND (GetFileAttr($basedir+"\"+$filename) & 16)
;? $basedir+"\"+$filename
GOTO "END"
ENDIF
IF $filename = "." Or $filename = ".."
$filename=Dir()
GOTO LOOP1
ELSE
;? $basedir
;? $filename " - Directory Name"
GOSUB create_zip
$filename=Dir()
;? "GOSUB create_zip"
ENDIF
:LOOP1
LOOP
EXIT

:create_zip
$cmd=" wzzip -a -ex -rp "
$cmd=$cmd+ Chr (34) + "C:\kix\springwood\$filename"+".zip" + Chr (34) +" "+ Chr (34) + "C:\kix\springwood\File Archive 2001\$filename" + Chr (34)
SHELL '%comspec% /c $cmd '
;? $cmd
; "Create Zip String"
?
RETURN
:END



yes it works.............
Phoe.

Les
(KiX Master)
2001-12-13 05:56 AM
Re: Automaticaly Archive each directory to a individual zip.

butchered? BUTCHERED? B U T C H E R E D?

I'm sorry... I'm surprised it works. You need to develop an understanding of what the code actually does, rather than just butcher it until you get results.

If you are to learn and advance to more difficult stuff as you put it, and I was your teacher, I'd make you do it all over.

Please don't get discouraged. It is not my intention to ridicule.

NTDOCAdministrator
(KiX Master)
2001-12-13 09:11 AM
Re: Automaticaly Archive each directory to a individual zip.

Butchered? Where is the Texas Chainsaw Masacare guy when you need him.

Pheonix, I think all that Les is meaning to say is that the spacing and indentation of code helps you to follow what is going on.

Kind of like IF may start line without indentation. Then the command you want to run if the IF statement is true would go on the next line but would be indented with at least a couple of spaces. Then the ENDIF or an ELSE would line up with the IF

The same goes for all the other code as well. Take a look at "most" of the code on the board and you should see a pattern. It does not have to be exactly like everyone elses, but similar spacing makes it easier to read and decode by yourself and others.

Hope this helps explain why.


MCA
Well I'm not sure what is going on. I'm supposed to be able to use KiXtart till we get into Active Directory, then I'm supposed to use VBS via WSH. However, I think KiXtart may have given me a lead up to another position or job with Corporate. I hear through the grapevine (means here-say, maybe not true) that Corporate is wanting me to do some scripting for them. I would assume KiXtart, since I don't have VBS experience. I'll let you know as I learn more. Thanks for the good words.

NTDOC...

[ 13 December 2001: Message edited by: NTDOC ]

andreasfc
(Fresh Scripter)
2001-12-13 03:31 PM
Re: Automaticaly Archive each directory to a individual zip.

I tried the script and it keeps running and zipping all the files over and over, what dir I do wrong?
I only changed the directory.


NTDOCAdministrator
(KiX Master)
2001-12-14 01:15 PM
Re: Automaticaly Archive each directory to a individual zip.

Dear andreasfc,

Don't know... Please post your code so that we can look at what might be wrong, or causing a problem.

andreasfc
(Fresh Scripter)
2001-12-14 04:15 PM
Re: Automaticaly Archive each directory to a individual zip.

Oke here is the code.

It is creating zip files over and over until I press Control-C

break on
?
;
$basedir="E:\Applications\Kixtart\Test\*.*"
$filename=Dir($basedir)

WHILE ($filename <> "") AND (@error = 0)
IF ($filename <> ".") AND ($filename <> "..") AND (GetFileAttr($basedir+"\"+$filename) & 16)
;? $basedir+"\"+$filename
GOTO "END"
ENDIF
IF $filename = "." Or $filename = ".."
$filename=Dir()
GOTO LOOP1
ELSE
;? $basedir
;? $filename " - Directory Name"
GOSUB create_zip
$filename=Dir()
;? "GOSUB create_zip"
ENDIF
:LOOP1
LOOP
EXIT

:create_zip
$cmd=" wzzip -a -ex -rp "
$cmd=$cmd+ Chr (34) + "E:\Applications\Kixtart\test\$filename"+".zip" + Chr (34) +" "+ Chr (34) + "E:\Applications\Kixtart\test\$filename" + Chr (34)
SHELL '%comspec% /c $cmd '
;? $cmd
; "Create Zip String"
?
RETURN
:END

Thanx

NTDOCAdministrator
(KiX Master)
2001-12-15 01:05 PM
Re: Automaticaly Archive each directory to a individual zip.

Hi andreasfc,

I'm sorry, but you changed a LOT of the code. Here below is working code for your situation.

code:
break on
$pkzip_mode="add" ; "move"
$basedir="E:\Applications\Kixtart\Test"
$filename=Dir("$basedir")
WHILE ($filename <> "") AND (@error = 0)
IF ($filename <> ".") AND ($filename <> "..") AND (GetFileAttr($basedir+"\"+$filename) & 16)
GOSUB create_zip
ENDIF
$filename=Dir()
LOOP
EXIT
:create_zip
IF ($pkzip_mode = "add")
$cmd=" wzzip -a -ex -rP "
ELSE
$cmd=" wzzip -m -ex -rP "
ENDIF
$cmd=$cmd+' "$basedir'+'\'+LTRIM(RTRIM($filename))+'.zip" "$basedir'+'\'+'$filename'+'\*.*" '
SHELL '%comspec% /c $cmd' ; <++++++++++
RETURN

Copy this code into Word and then copy/paste into your text editor and save the file as a .kix file and it should work fine.

andreasfc
(Fresh Scripter)
2001-12-15 07:12 PM
Re: Automaticaly Archive each directory to a individual zip.

Hello NTDOC,

I tried the script and it worked
thanx, but it only packs files which are in the subdir.
So how can I do this for files in the sam directory?

Thanx

Les
(KiX Master)
2001-12-16 12:41 AM
Re: Automaticaly Archive each directory to a individual zip.

andreasfc,
Since the enumeration of the DIRs, is my handywork, I'll speak to it. Read or reread my second post (fifth from the top) in this thread. There I try to explain what the code does. It was written to the requirement that PhoeniX put forth. If your requirement is different, the code can be changed.

The line "If ($Name <> ".") And ($Name <> "..") And (GetFileAttr($basedir+"\"+$name) & 16)" skips all parsed lines that dont match the requirements. Namely, it skips the DIR entries "." and ".." and also skips all lines that are not folders.

So, how to change the code depends on what you're trying to achieve. If you simply removed the folder check "(GetFileAttr($basedir+"\"+$name) & 16)", then every file encountered in $basedir would end up as an individual zip.

If, on the other hand, you want to zip the $basedir contents into just one zip file, then you don't even need the DIR enumeration. Just pass $basedir\*.* to the zip routine.

MCA
(KiX Supporter)
2001-12-16 02:44 AM
Re: Automaticaly Archive each directory to a individual zip.

Dear,

Your specification of variable $basedir is incorrect. Using \*.* has been
removed.
Also you are using a lot of GOTO statements which aren't necessary. Also we change
your code to reduce them. In our opinion is a script more readable without GOTO's.

code:

break on
;
$basedir="e:\Applications\Kixtart\Test"
$filename=Dir("$basedir")
WHILE ($filename <> "") AND (@error = 0)
IF ($filename <> ".") AND ($filename <> "..") AND (GetFileAttr($basedir+"\"+$filename) & 16)
; ? $basedir+"\"+$filename
GOSUB create_zip
ENDIF
$filename=Dir()
LOOP
EXIT

:create_zip
$cmd=" wzzip -a -ex -rp "
$cmd=$cmd+' "$basedir\'+LTRIM(RTRIM($filename))+'.zip" "$basedir\'+LTRIM(RTRIM($filename))+'" '
; SHELL '%comspec% /c $cmd ' ; <++++++++
? $cmd
RETURN



An output example can be for the "c:\windows" directory:
code:

wzzip -a -ex -rp "c:\windows\INF.zip" "c:\windows\INF"
wzzip -a -ex -rp "c:\windows\SYSTEM.zip" "c:\windows\SYSTEM"
wzzip -a -ex -rp "c:\windows\COMMAND.zip" "c:\windows\COMMAND"
wzzip -a -ex -rp "c:\windows\HELP.zip" "c:\windows\HELP"
wzzip -a -ex -rp "c:\windows\FONTS.zip" "c:\windows\FONTS"
wzzip -a -ex -rp "c:\windows\SendTo.zip" "c:\windows\SendTo"
wzzip -a -ex -rp "c:\windows\WANGSAMP.zip" "c:\windows\WANGSAMP"
wzzip -a -ex -rp "c:\windows\DESKTOP.zip" "c:\windows\DESKTOP"
wzzip -a -ex -rp "c:\windows\JAVA.zip" "c:\windows\JAVA"
wzzip -a -ex -rp "c:\windows\CONFIG.zip" "c:\windows\CONFIG"
wzzip -a -ex -rp "c:\windows\MEDIA.zip" "c:\windows\MEDIA"
wzzip -a -ex -rp "c:\windows\CURSORS.zip" "c:\windows\CURSORS"
wzzip -a -ex -rp "c:\windows\TEMP.zip" "c:\windows\TEMP"
wzzip -a -ex -rp "c:\windows\SYSBCKUP.zip" "c:\windows\SYSBCKUP"
wzzip -a -ex -rp "c:\windows\spool.zip" "c:\windows\spool"
wzzip -a -ex -rp "c:\windows\History.zip" "c:\windows\History"

We have comment the SHELL call to prevent an unexpected result during
a test run.
greetings.

PhoeniX
(Fresh Scripter)
2001-12-18 04:29 AM
Re: Automaticaly Archive each directory to a individual zip.

MCA,

I've tryed the code over and over, and I'm sure I understand it yet for me it will just roll through the routine and EXIT. I have no idear why, or can find a method to make it work.

code:
  
break on
;
$basedir="C:\windows"
$filename=Dir("$basedir")
WHILE ($filename <> "") AND (@error = 0)
IF ($filename <> ".") AND ($filename <> "..") AND (GetFileAttr($basedir+"\"+$filename) & 16)
? $basedir+"\"+$filename
GOSUB create_zip
ENDIF
$filename=Dir()
LOOP
EXIT
:create_zip
$cmd=" wzzip -a -ex -rp "
$cmd=$cmd+' "$basedir\'+LTRIM(RTRIM($filename))+'.zip" "$basedir\'+LTRIM(RTRIM($filename))+'" '
; SHELL '%comspec% /c $cmd ' ; <++++++++
? $cmd
RETURN

This is what I'm running for the sake of example and continuity I'm using C:\windows

This is the debug lines:
break on
$basedir="C:\windows"
$filename=Dir("$basedir")
WHILE ($filename <> "") AND (@error = 0)
IF ($filename <> ".") AND ($filename <> "..") AND (GetFileAttr($basedir+"\"+$fil
ename) & 16)
$filename=Dir()
LOOP
EXIT

I would say it can't find any directories.
The code would appear to work for everyone but me.

Extreamly bothered!!!

Phoe.

ShawnAdministrator
(KiX Supporter)
2001-12-18 05:12 AM
Re: Automaticaly Archive each directory to a individual zip.

Phoe,

What version of kix you running ?

-Shawn

PhoeniX
(Fresh Scripter)
2001-12-18 05:16 AM
Re: Automaticaly Archive each directory to a individual zip.

Shawn,

Kix Details:
C:\kix>kix32 /?
>>> KiXtart 95 3.63
Windows 2000 / NT 4.x / Windows 9x (logon) script processor.
Usage : KIX32 [script1] [...] [$var=123]

Phoe

ShawnAdministrator
(KiX Supporter)
2001-12-18 05:32 AM
Re: Automaticaly Archive each directory to a individual zip.

Hmmm... try this:


break on
;
$basedir="c:\windows"
$filename=dir("$basedir\*")
WHILE ($filename <> "") AND (@error = 0)
IF ($filename <> ".") AND ($filename <> "..") AND (GetFileAttr($basedir+"\"+$filename) & 16)
GOSUB "create_zip"
ENDIF
$filename=Dir()
LOOP
EXIT

:create_zip
$cmd=" wzzip -a -ex -rp "
$cmd=$cmd+' "$basedir\'+LTRIM(RTRIM($filename))+'.zip" "$basedir\'+LTRIM(RTRIM($filename))+'" '
; SHELL '%comspec% /c $cmd ' ; <++++++++
? $cmd
RETURN

Somethings fishy here though ...

-Shawn

[ 18 December 2001: Message edited by: Shawn ]

ShawnAdministrator
(KiX Supporter)
2001-12-18 06:01 AM
Re: Automaticaly Archive each directory to a individual zip.

Ok - yeah - MCA hit the nail on the head in the first post of this page ...

Try the script above ^

-Shawn

PhoeniX
(Fresh Scripter)
2001-12-18 06:16 AM
Re: Automaticaly Archive each directory to a individual zip.

Shawn,

wow it worked!!!!!!
Thanks heaps all, now to make sure I understand it & why it work for others and not me.


Phoe

MCA
(KiX Supporter)
2001-12-18 03:32 PM
Re: Automaticaly Archive each directory to a individual zip.

Dear,

We verify our code against kixtart 3.63 release and indeed code works diffe-
rent.
Only using Dir("c:\windows") means: search for file windows
in directory c:\.
With release 4.x it means: search for all entry in directory c:\windows.
Work around is: specify Dir("c:\windows\*.*".

code:

; Kixtart 3.63 + 4.x
;
break on
;
$basedir="e:\Applications\Kixtart\Test"
$filename=Dir("$basedir\*.*")
WHILE ($filename <> "") AND (@error = 0)
IF ($filename <> ".") AND ($filename <> "..") AND (GetFileAttr($basedir+"\"+$filename) & 16)
; ? $basedir+"\"+$filename
GOSUB create_zip
ENDIF
$filename=Dir()
LOOP
EXIT

:create_zip
$cmd=" wzzip -a -ex -rp "
$cmd=$cmd+' "$basedir\'+LTRIM(RTRIM($filename))+'.zip" "$basedir\'+LTRIM(RTRIM($filename))+'" '
; SHELL '%comspec% /c $cmd ' ; <++++++++
? $cmd
RETURN



An output example can be for the "c:\windows" directory:
code:

wzzip -a -ex -rp "c:\windows\INF.zip" "c:\windows\INF"
wzzip -a -ex -rp "c:\windows\SYSTEM.zip" "c:\windows\SYSTEM"
wzzip -a -ex -rp "c:\windows\COMMAND.zip" "c:\windows\COMMAND"


We have comment the SHELL call to prevent an unexpected result during
a test run.
PhoeniX "why it work for others and not me" we think "other persons are using it
in a kixtart 4.x environment.
greetings.