Re: zip files

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Well I have been testing code and this is great. So I integrated your code
and made several changes. I came across a issue, so I went back to your code
listed below to see if the same error occuurs. It did.

I updated zipfiles.txt and put more zips in the directory than in
zipfiles.txt. The output was as expected.

Next test was to run again when the number of zip files match the
zipfiles.txt. So basically no additional zips. In this case no files should
be deleted. Well I got an error.


The error is below:
Microsoft VBScript runtime error: Subscript out of range: 'i'

The script appears to be blowing up on line below:

If Instr(1, ReadLineTextFile, arrZIPNames(i), vbTextCompare) <> 0 then


Not sure how to fix. The script works great when there are more zips in the
directory than the txt file. But if no files should be deleted it throws
error.

Any Ideas?

Thanks so much for your help!




<persillade@xxxxxxxxxxx> wrote in message
news:1117816642.835683.314950@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>' VBScript source code
>
> ' This script compares the names of ZIP files in a folder against text
> file of ZIP names
> ' and deleted those ZIP files that are not found in the text file.
>
> dim arrZIPNames ' Store names of zips in folder
> dim arrMatches ' Store matches of zip file strings in text file vs.
> actual filenames
>
> const ForReading = 1
> Const STYLE_DOWNLOAD_DIR = "C:\Download\Style\"
> Const Source= "Deploy"
>
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> Set objShell = CreateObject("Wscript.Shell")
> set OutputFile = objFSO.CreateTextFile(STYLE_DOWNLOAD_DIR &
> "output.txt")
>
> set CheckFile = objFSO.OpenTextFile(STYLE_DOWNLOAD_DIR &
> "ZipFiles.txt", ForReading)
> Set styleFolder = objFSO.GetFolder(STYLE_DOWNLOAD_DIR)
>
> arrZIPNames = array()
> arrMatches = array()
> k = 0
>
> For Each zip in styleFolder.Files
> if UCase(right(zip.name,4)) = ".ZIP" Then
> Redim Preserve arrZIPNames(k)
> arrZIPNames(k) = zip.name
> k = k + 1
> OutputFile.WriteLine "Storing " & arrZIPNames(k - 1) & " in array
> element " & k - 1
> else
> ' do nothing
> end If
> next
>
> i = 0
> m = 0
>
> Do While CheckFile.AtEndofStream <> TRUE
> ReadLineTextFile = CheckFile.ReadLine
> For j = 1 to k
> If Instr(1, ReadLineTextFile, arrZIPNames(i), vbTextCompare) <> 0
> then
> OutputFile.WriteLine "Match found for " & arrZIPNames(i)
>
> Redim Preserve arrMatches(m)
> arrMatches(m) = arrZIPNames(i)
> m = m + 1
> i = i + 1
> ' Else
> ' OutputFile.WriteLine "Match NOT found for " & arrZIPNames(i)
> ' objFSO.DeleteFile(STYLE_DOWNLOAD_DIR & arrZIPNames(i))
> ' OutputFile.WriteLine STYLE_DOWNLOAD_DIR & arrZIPNames(i) & "
> deleted"
> End If
> Next
>
> Loop
>
> OutPutFile.WriteLine Ubound(arrMatches)
> For u = 0 to UBound(arrMatches)
> OutputFile.WriteLine arrMatches(u)
> Next
>
> match = false
> NotMatch = 0
>
> ' Compare arrMatches vs. directory
> For Each file in styleFolder.Files
> OutputFile.WriteLine "Now working on file " & file.name
> if UCase(right(file.name,4)) = ".ZIP" Then
> match = false
> NotMatch = 0
> For t = 0 to UBound(arrMatches)
> if Instr(1, file.name, arrMatches(0 + t), vbTextCompare) <> 0 then
> ' ok
> match = true
> OutputFile.WriteLine "Match found for " & file.name
> Else
> NotMatch = NotMatch + 1
> End If ' Instr
> Next
>
> if NotMatch = UBound(arrMatches) + 1 then
> OutputFile.WriteLine STYLE_DOWNLOAD_DIR & file.name & " deleted"
> objFSO.DeleteFile(STYLE_DOWNLOAD_DIR & file.name)
> End If
>
>
> End If
> Next
>
>
> Glad to assist,
> Chris Malone
>


.



Relevant Pages

  • Re: Serving ZIP files to IE using PHP
    ... > (IE thinks that ZIPs sent from a script are corrupt when they are not). ... PHP Classes - Free ready to use OOP components written in PHP ... PHP Reviews - Reviews of PHP books and other products ...
    (comp.lang.php)
  • Re: Serving ZIP files to IE using PHP
    ... Eric Ellsworth wrote: ... > (IE thinks that ZIPs sent from a script are corrupt when they are not). ... If this isn't what you did, you could sent a content-type header telling the ...
    (comp.lang.php)
  • Re: zip files
    ... times it deletes zips it is not suppose to. ... Storing Style4.zip in array element 0 ... dim arrMatches ' Store matches of zip file strings in text file vs.actual ... > zips do you have in the folder and how many in the check file? ...
    (microsoft.public.scripting.vbscript)
  • Serving ZIP files to IE using PHP
    ... (IE thinks that ZIPs sent from a script are corrupt when they are not). ... URL rewriting so that IE in theory should not know that it is receiving ...
    (php.general)
  • Serving ZIP files to IE using PHP
    ... (IE thinks that ZIPs sent from a script are corrupt when they are not). ... URL rewriting so that IE in theory should not know that it is receiving ...
    (comp.lang.php)