#61020 - 2001-12-14 04:15 PM
Re: Automaticaly Archive each directory to a individual zip.
|
andreasfc
Fresh Scripter
Registered: 2001-12-13
Posts: 18
|
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
|
|
Top
|
|
|
|
#61022 - 2001-12-15 07:12 PM
Re: Automaticaly Archive each directory to a individual zip.
|
andreasfc
Fresh Scripter
Registered: 2001-12-13
Posts: 18
|
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
|
|
Top
|
|
|
|
#61023 - 2001-12-16 12:41 AM
Re: Automaticaly Archive each directory to a individual zip.
|
Les
KiX Master
   
Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
|
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.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.
|
|
Top
|
|
|
|
#61025 - 2001-12-18 04:29 AM
Re: Automaticaly Archive each directory to a individual zip.
|
PhoeniX
Fresh Scripter
Registered: 2000-11-01
Posts: 22
Loc: Brisbane, QLD, Australia
|
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.
|
|
Top
|
|
|
|
#61027 - 2001-12-18 05:16 AM
Re: Automaticaly Archive each directory to a individual zip.
|
PhoeniX
Fresh Scripter
Registered: 2000-11-01
Posts: 22
Loc: Brisbane, QLD, Australia
|
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
|
|
Top
|
|
|
|
#61030 - 2001-12-18 06:16 AM
Re: Automaticaly Archive each directory to a individual zip.
|
PhoeniX
Fresh Scripter
Registered: 2000-11-01
Posts: 22
Loc: Brisbane, QLD, Australia
|
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 1179 anonymous users online.
|
|
|