Page 1 of 2 12>
Topic Options
#75401 - 2003-06-13 04:33 AM Recursive Zip
PhoeniX Offline
Fresh Scripter

Registered: 2000-11-01
Posts: 22
Loc: Brisbane, QLD, Australia
How can I make sure this script does not use text from the file name as an option in the zip string?

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

Thanks Heaps
Phoe

Top
#75402 - 2003-06-13 05:34 AM Re: Recursive Zip
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11567
Loc: CA
Phoenix,

Can you please explain in a little more detail what it is your trying to backup.

Files? Folders? You use $filename but you don't list/show it in code as to what it is defined as.

Here is an example of using the program. Just not sure what you mean or really want.

You DON'T want the completed zip file to contain any part of the file zipped? What do you want it named?

OR is it that the command is not working at all?

If so, maybe this code snipet will help.


$Files='"C:\My Documents\*.*"'
$Backup='C:\PROGRA~1\WinZip\WZZIP.EXE -ee -o -r -P "D:\Backup\backup.zip" $Files'
shell $Backup


[ 13. June 2003, 06:06: Message edited by: NTDOC ]

Top
#75403 - 2003-06-13 07:08 AM Re: Recursive Zip
PhoeniX Offline
Fresh Scripter

Registered: 2000-11-01
Posts: 22
Loc: Brisbane, QLD, Australia
NTDOC,

it goes as follows:

break on
;
$basedir="c:\cli\Clients"
$filename=dir("$basedir\*")
$archdir="c:\zip\"

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 '

It captures the root of each directory and archives everything below with the title of the root directory.zip

When it archives, it finds -v in some directory names - wzzip thinks this is an option.

Phoe.

Top
#75404 - 2003-06-13 11:00 AM Re: Recursive Zip
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11567
Loc: CA
Phoenix,

Please give this code a try. Make sure WZZIP.EXE is in your path, or use the full path as in my example.

NOTE:

-o = Change the Zip file's file date to the same as the newest file in the Zip file
-ee = extra (enhanced deflate - smallest file)
-r = Recurse into subfolders (include subfolders). This option requires the -p or -P option.
-p|P= Store folder names. A lower case p stores only the names of folders recursed
(subfolders included) via the -r option, while an upper case P stores all folder
information specified on the command line

Example: wzzip.exe -rp Would only contain the child folder names
wzzip.exe -rP Would contain the FULL path and child folder names



break on
$basedir="c:\cli\Clients"
$filename=dir("$basedir\*")
$archdir="c:\zip\"
WHILE ($filename <> "") AND (@error = 0)
IF ($filename <> ".") AND ($filename <> "..") AND (GetFileAttr($basedir+"\"+$filename) & 16)
shell 'C:\PROGRA~1\WinZip\WZZIP.EXE -eeorP $archdir$filename.zip $basedir\$filename\*.*'
ENDIF
$filename=dir()
LOOP
EXIT 1

Top
#75405 - 2003-06-13 11:20 AM Re: Recursive Zip
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11567
Loc: CA
WinZip beta 9
http://www.winzip.com/betawz.cgi
http://download.winzip.com/cgi-bin/auth/wzbeta90.exe?xfermode=80320448&srcip=24.205.6.96&From=&file=wzbeta90.exe

What's new in beta 9
http://www.winzip.com/whatsnew90.htm

WinZip Command Line Support Add-On 1.1 Beta
Requires WinZip beta 9
http://www.winzip.com/wzclineb.cgi
http://download.winzip.com/cgi-bin/auth/wzbetacl.exe?xfermode=58590595&srcip=24.205.6.96&From=&file=wzbetacl.exe

Top
#75406 - 2003-06-13 06:18 PM Re: Recursive Zip
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11567
Loc: CA
I guess the Phoenix has flown south for the Winter. Perhaps will return Monday [Roll Eyes]
Top
#75407 - 2003-06-13 06:57 PM Re: Recursive Zip
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22333
Loc: OK
doc, dude...
postprepping quotes? [Confused]
you should remember that your quotes most-likely never have correct syntax like we see above...
_________________________
!

download KiXnet

Top
#75408 - 2003-06-13 07:50 PM Re: Recursive Zip
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11567
Loc: CA
Yeah, I know, you're right. I manually massaged it to work. Hey, what can I say dude... I love your program too much and try to use it for unintended purposes. [Big Grin]
Top
#75409 - 2003-06-14 04:04 AM Re: Recursive Zip
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22333
Loc: OK
I could make it work for that purpose too [Big Grin]
if you would just ask me to! [Wink]
_________________________
!

download KiXnet

Top
#75410 - 2003-06-14 09:26 AM Re: Recursive Zip
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11567
Loc: CA
Hey that would be great Lonkero.

Would you make it work for that purpose too? PLEASE!!!

Top
#75411 - 2003-06-16 05:32 AM Re: Recursive Zip
PhoeniX Offline
Fresh Scripter

Registered: 2000-11-01
Posts: 22
Loc: Brisbane, QLD, Australia
NTDOC,

I think I've found the problem. Its not the way that the variables are passed to shell. Its wzzip, I just did a cmd line test of it and it failed showing that you can not have -v combined with other options.

wzzip -a -ex -rp "c:\files\thisdir.zip" "c:\files\exdir -v exdir\*.*"

Well now I have to find another way around. Maybe a rename script.

Thanks for your help

Phoe

Top
#75412 - 2003-06-16 09:36 AM Re: Recursive Zip
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11567
Loc: CA
Phoenix,

I'm not having any problem creating the zip file on the command line.
Here is what I have.

KIXTART 4.21
Windows 2000 SP3
IE 6.01
Winzip 9.0 beta
Winzip Command-line add-on 1.1 (for Winzip 9 beta)

Here is the full commandline used in a DOS Window:
(I don't have WZZIP.EXE in path so I use full path)

C:\PROGRA~1\WinZip\WZZIP.EXE -a -ex -rp "c:\files\thisdir.zip" "c:\files\exdir -v exdir\*.*"

Here is the listing of the files and directories I have.

quote:
C:\FILES\- V -ex -v
C:\FILES\- V -ex -v\egensock.cpp
C:\FILES\- V -ex -v\fgensock.cpp
C:\FILES\- V -ex -v\ggensock.cpp
C:\FILES\-v
C:\FILES\-v\Rebel
C:\FILES\-v\Rebel\Contents.txt
C:\FILES\-v\Rebel\Readme.txt
C:\FILES\-v\Rebel\Temp - V -v
C:\FILES\-v\Rebel\Temp - V -v\NSDSESS.TXT
C:\FILES\-v\moose.jpg
C:\FILES\Clients
C:\FILES\Clients\files.txt
C:\FILES\Compaq
C:\FILES\Compaq\NextGen
C:\FILES\Compaq\NextGen\IBM
C:\FILES\Compaq\NextGen\IBM\- v - ex -r -p -P -ee
C:\FILES\Compaq\NextGen\IBM\- v - ex -r -p -P -ee\-v
C:\FILES\Compaq\NextGen\IBM\- v - ex -r -p -P -ee\Copy of -v
C:\FILES\Compaq\NextGen\IBM\- v - ex -r -p -P -ee\Copy of sdk45y.txt
C:\FILES\Compaq\NextGen\IBM\- v - ex -r -p -P -ee\sdk45y.txt
C:\FILES\Compaq\NextGen\IBM\Bakegensock.cpp
C:\FILES\Compaq\NextGen\IBM\Bakfgensock.cpp
C:\FILES\Compaq\NextGen\IBM\Bakggensock.cpp
C:\FILES\Compaq\NextGen\egensock.cpp
C:\FILES\Compaq\NextGen\fgensock.cpp
C:\FILES\Compaq\NextGen\ggensock.cpp
C:\FILES\Compaq\fort.txt
C:\FILES\GENSOCK
C:\FILES\GENSOCK\gensock.cpp
C:\FILES\GENSOCK\gensock.h
C:\FILES\HP
C:\FILES\HP\-ex
C:\FILES\HP\-ex\snsock.cp
C:\FILES\HP\Copy of leftck.cpp
C:\FILES\HP\leftck.cpp
C:\FILES\Testing -v
C:\FILES\Testing -v\egensock.cpp
C:\FILES\Testing -v\fgensock.cpp
C:\FILES\Testing -v\ggensock.cpp
C:\FILES\exdir -v exdir
C:\FILES\exdir -v exdir\egensock.cpp
C:\FILES\exdir -v exdir\fgensock.cpp
C:\FILES\exdir -v exdir\ggensock.cpp
C:\FILES\files.txt

It created a single zip file with all folders.

I use the -ee switch because is creates a smaller file then -ex
that was the old highest compression switch, now it is -ee
I also use -rP (Capital P) to get the full path of directories in
the zip file as well.

I then modified the KiXtart file to use the new path
(not the same path you listed before) and re-ran the code.

I got the same error. That is because the quotes were not sufficient
to capture all of the information.

I modified the command line to this: (you don't need a space and - switch for each option
it can be supplied with a single - followed by multiple options.
shell 'C:\PROGRA~1\WinZip\WZZIP.EXE -eeorP "$archdir$filename.zip" "$basedir\$filename\*.*"'

This now produces the following files in the C:\ZIP folder:
- V -ex -v.zip
Clients.zip
Compaq.zip
exdir -v exdir.zip
GENSOCK.zip
HP.zip
Testing -v.zip
-v.zip

Each zip file contains all the files within its own folder and includes the FULL path.

Please retry the code EXACTLY as I've supplied and you should find it now zips up the files as expected.


break on
$basedir="c:\files"
$filename=dir("$basedir\*")
$archdir="c:\zip\"
WHILE ($filename <> "") AND (@error = 0)
IF ($filename <> ".") AND ($filename <> "..") AND (GetFileAttr($basedir+"\"+$filename) & 16)
shell 'C:\PROGRA~1\WinZip\WZZIP.EXE -eeorP "$archdir$filename.zip" "$basedir\$filename\*.*"'
ENDIF
$filename=dir()
LOOP
EXIT 0

Top
#75413 - 2003-06-17 09:32 AM Re: Recursive Zip
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11567
Loc: CA
Phoenix,

Did you get a chance to run this?

Top
#75414 - 2003-06-21 04:04 AM Re: Recursive Zip
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11567
Loc: CA
Phoenix - WHAT'S UP

Another flash in the pan? Come on back, the waters fine.

Why do we get so many people come by and ask a question, then they either don't check the answer or they get the answer and never come back?

KiXtart.org is a GREAT place with a lot of good people. Rod was saying that something like 17,000 people have downloaded Shawn's KiXforms DLL. That is a lot of people, a rather large SILENT Majority so it would seem.

Top
#75415 - 2003-06-25 06:47 AM Re: Recursive Zip
PhoeniX Offline
Fresh Scripter

Registered: 2000-11-01
Posts: 22
Loc: Brisbane, QLD, Australia
NTDOC,

yeah I'm still here working on this. I just haven't been able to get back to it over the last week.

You said your script created a single zip file?
"It created a single zip file with all folders. "

I've just installed winzip9 +cmdline and I'll get back into it now.

Thanks for your help
Phoe.

Top
#75416 - 2003-06-25 07:39 AM Re: Recursive Zip
PhoeniX Offline
Fresh Scripter

Registered: 2000-11-01
Posts: 22
Loc: Brisbane, QLD, Australia
NTDOC,

Tested the script with winzip 8 +cmdline and wzzip switches

Tested the script with winzip 9 beta +cmdline and
wzzip switches

Winzip 8 reads the line and if it sees -v or - v in the string passed to the command line it will fail.

ERROR: option -v, -vi cannot be combined with option -a, -d, -f, -i, -u
Program is terminating!

Winzip 9 does not have this problem.

Perhaps I should test other products for the archive job too.

Top
#75417 - 2003-06-25 10:39 AM Re: Recursive Zip
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11567
Loc: CA
Phoenix,

What OS are you using? I tested this on both Windows 95 and 2000 using WinZip v8.0 originally.

Then I upgraded to WinZip 9 beta and it still worked fine.

Check your path to make sure you don't have an OLD version of the command line tools somewhere.

Also copy the code exactly as above. I have run it many times and I do not get that error anymore.

The error was caused by a misuse of quotes "" for the %comspec% call. With the correct usage it works just fine.

It creates a zip file for every top folder under the target folder with recursive files in each zip for each folder.

Top
#75418 - 2003-06-27 01:31 AM Re: Recursive Zip
PhoeniX Offline
Fresh Scripter

Registered: 2000-11-01
Posts: 22
Loc: Brisbane, QLD, Australia
NTDOC,

I ran your code posted: posted 16. June 2003 09:36.

It functions with winzip9 beta - cmd line
but in winzip8 cmd line, it will fail on file names with -v in them.
(0004642 Rider-Bell Denise Marilyn -v Carison)

This is the code I ran, with the change for the winzip8 cmd line.
--------------
break on
$basedir="c:\files"
$filename=dir("$basedir\*")
$archdir="c:\zip\"
WHILE ($filename <> "") AND (@error = 0)
IF ($filename <> ".") AND ($filename <> "..") AND (GetFileAttr($basedir+"\"+$filename) & 16)
shell 'C:\PROGRA~1\WinZip\WZZIP.EXE -a -ex -rp "$archdir$filename.zip" "$basedir\$filename\*.*"'
ENDIF
$filename=dir()
LOOP
EXIT 0
------------

Tested on a WindowsXP WZ8+cmdline

I hope I can see it your way, then it may work.
Thanks for your patience
Phoe.

Top
#75419 - 2003-06-27 10:40 AM Re: Recursive Zip
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11567
Loc: CA
Okay Phoenix...

It was a pain in the butt, but I un-installed WinZip 9 and rebooted. Then I re-installed all Winzip 8.0 and command-line add-on v1.0

I can confirm that 8.0 DOES NOT work. Version 9.0 beta DOES WORK fine.

Not sure what you're really trying to do here though. There are plenty of applications and methods for backing up files or systems.

Using Winzip for this purpose is okay for a quicky, but not very robust. Why do you need separate zip files for each folder?

Why not upgrade to Winzip 9 beta? It is a free upgrade for registered users.

Maybe if you give us more details on what the FULL STORY is for the archiving purposes we can either script something better or recommend a better product.

In the same/similar category as Winzip, there is WinRaR too.

Top
#75420 - 2003-06-27 11:02 AM Re: Recursive Zip
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22333
Loc: OK
if you want to compress the files (no need for that either) during the process, you could use windows cab-files and the udf that creates them.

they are browseable and extractable via windows explorer or extract.exe (part of windows) or winrar (or any other good packaging util)
_________________________
!

download KiXnet

Top
Page 1 of 2 12>


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 191 anonymous users online.
Newest Members
thequeen, ameliaryan, shalomsalami, dkdssdk, Vroon
17639 Registered Users

Generated in 0.041 seconds in which 0.011 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org