Creato da developer.web il 14/03/2014
Web Developer
 

Chi puņ scrivere sul blog

Solo l'autore puņ pubblicare messaggi in questo Blog e tutti gli utenti registrati possono pubblicare commenti.
 

Area personale

 

Archivio messaggi

 
 << Luglio 2024 >> 
 
LuMaMeGiVeSaDo
 
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
 
 

I miei link preferiti

 

Cerca in questo Blog

  Trova
 

Tag

 
RSS (Really simple syndication) Feed Atom
 
 

Ultime visite al Blog

developer.webcarloserravalleLisa20141RangoBassofugadallanimaMaAnkeNoXkeSiBardamutoacer.250autumninrom0Alberi_Nuovilubopokant.333quinoa1977valentinachiummofabrizievole
 

NO TROLL

 

 

« Beyond Good & Evil - Aku...VBScript Elencante VBS v 2.0 »

VBScript Cercare stringa all'interno di un gruppo di files

Post n°10 pubblicato il 16 Luglio 2015 da developer.web
 

Dim list, flist, listArr, listItem, oShell, oItem, jobFolder, objFso
Dim oDir, oFolder, oFolders, oFile, oFiles, a, path

list = ""
flist = ""

Set oShell = CreateObject("Shell.Application")
Set oItem = oShell.BrowseForFolder(0, "Scegli la cartella di lavoro:", 0, "")
If oItem Is Nothing Then
    Wscript.Quit
End If
jobFolder = oItem.Self.Path & ""
Set oShell = Nothing
Set oItem = Nothing

Dim vIns : vIns = InputBox ("Inserisci cosa cercare:", "Ricerca", "")
If vIns = "" Then
    Wscript.Quit
End If

list = "?" & jobFolder

Do Until (InStr(1, list, "?") = 0)
    listArr = Split(list, "^")
    For Each listItem In listArr
        a = Mid(listItem, 1, 1)
        path = Mid(listItem, 2)
        If a = "?" Then
            Set objFso = CreateObject("Scripting.FileSystemObject")
            Set oDir = objFso.GetFolder(path)
            Set oFolders = oDir.SubFolders
            For Each oFolder In oFolders
                list = list & "^" & "?" & path & oFolder.Name & ""
            Next
            Set objFso = Nothing
            Set oDir = Nothing
            Set oFolders = Nothing
            list = Replace(list, "?" & path, path, 1, 1)
        End If
    Next
Loop

listArr = Split(list, "^")

For Each path In listArr
    Set objFso = CreateObject("Scripting.FileSystemObject")
    Set oDir = objFso.GetFolder(path)
    Set oFiles = oDir.Files
    For Each oFile In oFiles
        flist = flist & "^" & path & oFile.Name
    Next
    Set objFso = Nothing
    Set oDir = Nothing
    Set oFiles = Nothing
Next

Dim filesys, filetxt, fcontent, s
sresult = ""
listArr = Split(flist, "^")

For Each path In listArr
    If path <> "" Then
        Set filesys = CreateObject("Scripting.FileSystemObject")
        Set filetxt = filesys.OpenTextFile(path, 1, True)
        fcontent = filetxt.ReadAll
        s = InStr(1, fcontent, vIns)
        If s > 0 Then
            sresult = sresult & "#" & s & Replace(path, jobFolder, ".") & vbCrLf
        End If
        filetxt.Close
        Set filesys = Nothing
        Set filetxt = Nothing
    End If
Next

If sresult = "" Then
    MsgBox "Nessun risultato trovato", 0, ":-("
Else
    MsgBox sresult
End If

La URL per il Trackback di questo messaggio è:
https://blog.libero.it/developerweb/trackback.php?msg=13244389

I blog che hanno inviato un Trackback a questo messaggio:
Nessun trackback

 
 
 
 

© Italiaonline S.p.A. 2024Direzione e coordinamento di Libero Acquisition S.á r.l.P. IVA 03970540963