Couplage de script VBS

Bonjour,

je souhaiterai coupler deux scripts VBS qui fonctionnent bien.

Le but étant de lister les images d'un dossier en affichant la dimension de l'image et son poids (grace à getdetailsof)

voici le premier script :

Dim stRep 'Nom du répertoire à parcourir
Dim oFSO,oFl
Set oFSO = CreateObject("Scripting.FileSystemObject")
stRep = "C:\Tmp"
If oFSO.FolderExists(stRep) Then
For each oFl in oFSO.GetFolder(stRep).Files
Wscript.Echo oFl.Name
Next
End If


et le deuxième

Const DIMENSIONS = 31
CONST WIDTH = 162
CONST HEIGTH = 164

Set oShell = CreateObject ("Shell.Application")
Set oFolder = oShell.Namespace ("d:\")
Set oFile = oFolder.ParseName("clé.bmp")

strDimensions = oFolder.GetDetailsOf(oFile, DIMENSIONS)
strWidth = oFolder.GetDetailsOf(oFile, WIDTH)
strHeigth = oFolder.GetDetailsOf(oFile, HEIGTH)

WScript.Echo "Dimensions: " & strDimensions & vbNewLine & _
"Width: " & strWidth & vbNewLine & _
"Height: " & strHeigth


En poussant le vice un peu plus loin si ça pouvait etre inscrit dans un fichier txt ça serait cool...

En vous remericant d'avance.

4 réponses

  1. Contributeur
    Oui :-)
    Je ne connais pas bien le VBScript, je serais plutôt pour les autres VB
    Cherche du côté de Open pour ouvrir un fichier du genre..
    Open "Fichier.txt" for output as #1
    Pour écrite voir Write du genre
    Write #1, oFl.Name , "Dimensions: " , strDimensions, _
    "Width: " , strWidth & vbNewLine, _
    "Height: ", strHeigth

    Et quand fini : Close #1
    Vois ce que tu peu faire avec ça.
    A+
    1. ok merci cool ça fonctionne par contre ça n'écrit pas dans un fichier....

      ;...je suis chiant

      :-)
      1. Contributeur
        En extrapolant un peu
        Const DIMENSIONS = 31
        Const WIDTH = 162
        Const HEIGTH = 164
        Dim stRep 'Nom du répertoire à parcourir
        Dim oFSO, oFl
            Set oShell = CreateObject("Shell.Application")
            Set oFSO = CreateObject("Scripting.FileSystemObject")
            stRep = "C:\Tmp"
            If oFSO.FolderExists(stRep) Then
                Set oFolder = oShell.Namespace(stRep)
                For Each oFl In oFSO.GetFolder(stRep).Files
                    Set oFile = oFolder.ParseName(oFl.Name)
                    strDimensions = oFolder.GetDetailsOf(oFile, DIMENSIONS)
                    strWidth = oFolder.GetDetailsOf(oFile, WIDTH)
                    strHeigth = oFolder.GetDetailsOf(oFile, HEIGTH)
                    WScript.Echo oFl.Name & "Dimensions: " & strDimensions & vbNewLine & _
                    "Width: " & strWidth & vbNewLine & _
                    "Height: " & strHeigth
                Next
            End If

        A+
        1. Contributeur
          Bonjour,
          Si je comprend bien tu veux avoir les noms et données des fichiers.
          Si oui, Pas besoin de ta deuxième fonction, l'objet Fso fais cela très bien, même plus.
          A+
          Edit: Pas bien lu, tu veux les dimensions d'un bmp et effectivement Fso ne fait pas ça.
          Si tu te cognes à un pot et que ça sonne creux, c'est pas forcément le pot qui est vide. ;-)(Confucius)
          NOTE : Je ne répond pas aux MP pour les questions techniques.