#127334 - 2004-10-03 02:44 PM
checking folder
|
mbu10
Fresh Scripter
Registered: 2004-09-08
Posts: 27
|
hi guys looking if some one could help me with this looking to check a folder for 6 files(which i would no the name) now if any files are missing extract them from a zip file somewhere else on another drive then run a shell on the files that were missing only
thanks
|
|
Top
|
|
|
|
#127336 - 2004-10-03 03:25 PM
Re: checking folder
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
Here's a quick template script for doing twoor more files like this, just replace the ? lines with shell statements that extract and work on the files:
Code:
break on
$folder = "."
$files = "x.tmp", "y.tmp", "z.tmp"
for each $file in $files
if exist($folder + "\" + $file) = 0
? "pkunzip $file from somwhere to $folder\$file"
? "run shell on $folder\$file"
endif
next
Its a start,
-Shawn
|
|
Top
|
|
|
|
#127338 - 2004-10-03 07:45 PM
Re: checking folder
|
mbu10
Fresh Scripter
Registered: 2004-09-08
Posts: 27
|
been tryint htis but unzips all the files any reason why ? been working for a couple of hours cannot figure why is doing them al
here
$folder = "C:\foldera"
$files = "$isaname1", "$isaname2", "$isaname3", "$isaname4", "$isaname5"
for each $file in $files
if exist($folder + "\" + $file) = 0
Shell "%COMSPEC% /C C:\kix\pkzipc.exe -extract C:\foldera\isafile.zip "$files" $folder\$file" ? "run shell on $folder\$file"
endif
next
thanks
|
|
Top
|
|
|
|
#127340 - 2004-10-03 08:07 PM
Re: checking folder
|
mbu10
Fresh Scripter
Registered: 2004-09-08
Posts: 27
|
well it seemed easier for me to understand
|
|
Top
|
|
|
|
#127345 - 2004-10-03 08:58 PM
Re: checking folder
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11629
Loc: CA
|
Hmmm... thinking you are also using the old DOS PKUNZIP which only handles 8.3 file structure. (not sure, just a guess)
Please make sure you are using the WinZip 9 compliant Command Line tools which support long file names. Also take a look at this posting which might be of interest or help you further. Recursive Zip http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Number=75192
|
|
Top
|
|
|
|
#127346 - 2004-10-03 09:07 PM
Re: checking folder
|
mbu10
Fresh Scripter
Registered: 2004-09-08
Posts: 27
|
thanks for all the help guys but still not working right the following code is running fine extracts files to the correct path but is extracting them all and not just the files i need any ideas?
Dim $folder, $file, $files $folder = 'C:\foldera\' $files = '$isaname1','$isaname2','$isaname3','$isaname4','$isaname5' For Each $file In $files If NOT Exist($folder + $file) Shell '%COMSPEC% /C C:\kix\WZUNZIP.exe -e C:\foldera\isafile.zip C:\foldera\"$file" C:\foldera\ ' Shell $folder + $file EndIf Next
thanks again
|
|
Top
|
|
|
|
#127347 - 2004-10-03 09:19 PM
Re: checking folder
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11629
Loc: CA
|
You need to build a list of the files you want to extract. Using simply the -e tells WinZip to extract all files.
From the manual
Quote:
-@listfile Create a file listing all the files that would be unzipped if this option were not specified. Hint: remember to use the leading dash to create a list. Leave out the leading dash to use a list of files in a WZUNZIP command.
Copyright © 2004 WinZip Computing, Inc. All rights reserved.
Notice though that KiXtart using the @ sign as well so you will need to double up to use the @ sign in your code. -@@
Give that a try and let us know how it goes. I see now that you're using the correct version of Command Line "WZUNZIP.EXE"
Quote:
Examples
wzunzip test.zip
Extracts all files from Test.zip to the current directory.
wzunzip test.zip abc.txt
Extracts abc.txt from test.zip.
wzunzip -d test.zip
Extracts all files from Test.zip, recreating the directory structure from folder information stored in the Zip file. New directories are created if necessary. Hint: if folder information is stored in the Zip file, you will almost always want to use the -d option.
wzunzip -d test.zip c:\docs\
Extracts all files from Test.zip, recreating the directory structure from folder information stored in the Zip file. The files are stored under C:\DOCS. For example, if the file One.doc has no folder information in the Zip file, it would be stored as C:\Docs\One.doc; if the file Two.doc is stored in the Zip file with the folder Budget\, it would be stored as C:\Docs\Budget\Two.doc.
wzunzip test.zip @files.lst
Extracts from test.zip all files that are listed in the text file files.lst.
wzunzip -v test.zip
Lists contents of Test.zip.
wzunzip -v test.zip *.txt
Lists all files with a .txt extension in test.zip.
Copyright © 2004 WinZip Computing, Inc. All rights reserved.
|
|
Top
|
|
|
|
#127349 - 2004-10-03 09:37 PM
Re: checking folder
|
mbu10
Fresh Scripter
Registered: 2004-09-08
Posts: 27
|
Just a thought whan i am tying to unzip and i am saying which file to unzip in the "file" part would this not pass the single file value to winzip
it just that after i have unzipped the single file which does not exist i need to run another shell command on it stright away then start testing for any other missing files thanks again i have passed varibles to winzip before so stating a $file into winzip would it not just pass the single varible to winzip and not the entire files varible(has all the files in it thanks martin
|
|
Top
|
|
|
|
#127350 - 2004-10-03 11:56 PM
Re: checking folder
|
mbu10
Fresh Scripter
Registered: 2004-09-08
Posts: 27
|
ok this is the only way i could do it only ever going to be looking for 5 files in a certain directory and this is the code i found does now work
bit long winded and sure better way of doing it but i know it works thanks
;This check to see if files are in the correct folder for the isa files ;if they are not it extracts them from the zip file then runs the gawk file ;to the correct folder and sorts them
If NOT Exist('C:\foldera\$isaname1') Shell '%COMSPEC% /C C:\kix\WZUNZIP.exe -e C:\foldera\isafile.zip "$isaname1" C:\foldera\ ' Shell 'need the gawk command in here to make sure is done right then goes to next zip' Else ? "SORRY NOT COPYING FILE EXISTS" EndIf
If NOT Exist('C:\foldera\$isaname2') Shell '%COMSPEC% /C C:\kix\WZUNZIP.exe -e C:\foldera\isafile.zip "$isaname2" C:\foldera\ ' Shell 'need the gawk command in here to make sure is done right then goes to next zip' Else ? "SORRY NOT COPYING FILE EXISTS" EndIf
If NOT Exist('C:\foldera\$isaname3') Shell '%COMSPEC% /C C:\kix\WZUNZIP.exe -e C:\foldera\isafile.zip "$isaname3" C:\foldera\ ' Shell 'need the gawk command in here to make sure is done right then goes to next zip' Else ? "SORRY NOT COPYING FILE EXISTS" EndIf
If NOT Exist('C:\foldera\$isaname4') Shell '%COMSPEC% /C C:\kix\WZUNZIP.exe -e C:\foldera\isafile.zip "$isaname4" C:\foldera\ ' Shell 'need the gawk command in here to make sure is done right then goes to next zip' Else ? "SORRY NOT COPYING FILE EXISTS" EndIf
If NOT Exist('C:\foldera\$isaname5') Shell '%COMSPEC% /C C:\kix\WZUNZIP.exe -e C:\foldera\isafile.zip "$isaname5" C:\foldera\ ' Shell 'need the gawk command in here to make sure is done right then goes to next zip' Else ? "SORRY NOT COPYING FILE EXISTS" EndIf
|
|
Top
|
|
|
|
#127352 - 2004-10-04 01:00 AM
Re: checking folder
|
mbu10
Fresh Scripter
Registered: 2004-09-08
Posts: 27
|
well they are isa log files each one is 1.7 gig in size but when zipped the are only 2% of original size have 17 of them (one for every server) so cannot just copy 34-50 gig over the network but once zipped which happen at every isa server before transfer then need to check on the logging server to check if the files are there (copy them from the zip file if they are not) before i gawk them into net tracker
|
|
Top
|
|
|
|
#127353 - 2004-10-04 08:33 AM
Re: checking folder
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11629
Loc: CA
|
Here is some smaller/cleaner code that should perform the task just fine. Let me know how it works out. This code should be NoVarInStrings compliant.
Copy the code and paste it to Wordpad, then copy it from Wordpad and paste it to notepad or other text editor and save the file.
NOTE This is basically the code that Les and Shawn laid out for you already. I simply placed it into a full working code example.
Code:
Break On
Dim $SO,$Folder,$File,$FileList
$SO=SetOption('Explicit','On')
$SO=SetOption('NoVarsInStrings','On')
$Folder='C:\FOLDERA\'
$FileList='file1.txt','file2.txt','file3.txt','file4.txt','file5.txt'
For Each $File In $FileList
If Not Exist($Folder + $File)
Shell '%COMSPEC% /C C:\kix\WZUNZIP.exe -e ' + $Folder + 'isafile.zip ' + $File + ' ' + $Folder + ' >NUL 2>NUL'
EndIf
Next
SPACING OF QUOTES IS IMPORTANT
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 675 anonymous users online.
|
|
|