#60999 - 2001-12-04 01:42 AM
Automaticaly Archive each directory to a individual zip.
|
PhoeniX
Fresh Scripter
Registered: 2000-11-01
Posts: 22
Loc: Brisbane, QLD, Australia
|
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.
|
Top
|
|
|
|
#61001 - 2001-12-04 03:32 AM
Re: Automaticaly Archive each directory to a individual zip.
|
PhoeniX
Fresh Scripter
Registered: 2000-11-01
Posts: 22
Loc: Brisbane, QLD, Australia
|
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.
|
Top
|
|
|
|
#61002 - 2001-12-04 05:17 AM
Re: Automaticaly Archive each directory to a individual zip.
|
NTDOC
Administrator
Registered: 2000-07-28
Posts: 11623
Loc: CA
|
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 ]
|
Top
|
|
|
|
#61003 - 2001-12-04 05:55 AM
Re: Automaticaly Archive each directory to a individual zip.
|
Les
KiX Master
Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
|
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 ]
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.
|
Top
|
|
|
|
#61004 - 2001-12-04 10:38 AM
Re: Automaticaly Archive each directory to a individual zip.
|
NTDOC
Administrator
Registered: 2000-07-28
Posts: 11623
Loc: CA
|
There you go... Les is more of a KiX purist then I.
|
Top
|
|
|
|
#61007 - 2001-12-10 08:13 AM
Re: Automaticaly Archive each directory to a individual zip.
|
PhoeniX
Fresh Scripter
Registered: 2000-11-01
Posts: 22
Loc: Brisbane, QLD, Australia
|
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
|
Top
|
|
|
|
#61011 - 2001-12-12 03:20 AM
Re: Automaticaly Archive each directory to a individual zip.
|
PhoeniX
Fresh Scripter
Registered: 2000-11-01
Posts: 22
Loc: Brisbane, QLD, Australia
|
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
|
Top
|
|
|
|
#61012 - 2001-12-12 10:55 AM
Re: Automaticaly Archive each directory to a individual zip.
|
NTDOC
Administrator
Registered: 2000-07-28
Posts: 11623
Loc: CA
|
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 ]
|
Top
|
|
|
|
#61015 - 2001-12-13 04:40 AM
Re: Automaticaly Archive each directory to a individual zip.
|
PhoeniX
Fresh Scripter
Registered: 2000-11-01
Posts: 22
Loc: Brisbane, QLD, Australia
|
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.
|
Top
|
|
|
|
#61017 - 2001-12-13 09:11 AM
Re: Automaticaly Archive each directory to a individual zip.
|
NTDOC
Administrator
Registered: 2000-07-28
Posts: 11623
Loc: CA
|
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 ]
|
Top
|
|
|
|
#61018 - 2001-12-13 03:31 PM
Re: Automaticaly Archive each directory to a individual zip.
|
andreasfc
Fresh Scripter
Registered: 2001-12-13
Posts: 18
|
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.
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
1 registered
(Allen)
and 466 anonymous users online.
|
|
|