cs_chamcham
Messages postés7Date d'inscriptionlundi 16 mai 2005StatutMembreDernière intervention15 mars 2006
-
13 mars 2006 à 16:48
cs_chamcham
Messages postés7Date d'inscriptionlundi 16 mai 2005StatutMembreDernière intervention15 mars 2006
-
14 mars 2006 à 10:19
Bonjour voici mon souci :
Je voudrais retrouver dans un certain dossier tous les fichiers d'un meme type.
Ex: avoir la liste de tous mes gif dans mon dossier image, et non d'avoir tous mes jpg,bmp,gif,...
Voici mon 1er prog (il a quelque erreur mais il marche):
Set objShell = CreateObject ("Shell.Application")
Set objFolder = objShell.Namespace ("C:\image")
Set objFSO = CreateObject("Scripting.FileSystemObject")
SET Rapport = ObjFSO.OpenTextFile("C:\Documents and Settings\Thomas\Desktop\test2.xls",2,TRUE,0)
Dim arrHeaders(13)
For i = 0 to 13
arrHeaders(i) = objFolder.GetDetailsOf (objFolder.Items, i)
Next
For Each strFileName in objFolder.Items
For i = 0 to 13
If i <> 9 then
Rapport.writeline arrHeaders(i) _
& ": " & objFolder.GetDetailsOf (strFileName, i)
End If
Next
Next
objFile.Name
Ce prog me donne toute les infos sur les images du dossier (ce que je veux) mais le hic y a les autres types de fichier non souhaité.
Voici donc mon 2nd prog (celui ci sans erreur) :
strComputer = "."
Set objFSO = CreateObject("Scripting.FileSystemObject")
SET Rapport = ObjFSO.OpenTextFile("C:\Documents and Settings\T5784900\Desktop\rapport.xls",2,TRUE,0)
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
("Select * from CIM_DataFile where Extension = 'gif'")
For Each objFile in colFiles
Rapport.writeline objFile.Name
Next
Ce prog me donne bien toutes mes images gif (mais sans le detail du 1er prog) et il recherche dans tous les autres disques toutes les images gif.
donc ma question au final : C possible un mixe des 2 pour n'en faire qu'un ??
Merci d'avance pour les reponses
PS: C la 1er fois que je fais du VBScript donc pour toutes les erreurs que vous voyez merci de me les dire SVP ou comment ameliorer mes prog si possible.
cs_JMO
Messages postés1854Date d'inscriptionjeudi 23 mai 2002StatutMembreDernière intervention24 juin 201827 13 mars 2006 à 18:01
Bonjour ...
Sur me même principe que Ant8386
Set Fso = Wscript.CreateObject("Scripting.FileSystemObject")
Set Afolder = fso.GetFolder("d:\zz")
Recherche AFolder
Function Recherche (ByRef AFolder)
For Each AFile In AFolder.Files
If UCase(FSO.GetExtensionName(AFile.Path)) = "GIF" Then
MsgBox AFile.Path
End if
Next
For Each SubF In AFolder.SubFolders
Recherche SubF
Next
End Function
cs_chamcham
Messages postés7Date d'inscriptionlundi 16 mai 2005StatutMembreDernière intervention15 mars 2006 14 mars 2006 à 10:19
J'ai encore besoin de vous car j'ai adapté vos prog avec le mien mais mon souci et que je genere un fichier Excel pour avoir le resultat et dans celui ci je souhait avoir les details du fichier.
Voici un resultat souhaité dans mon fichier Excel genéré :
C:\image\new_018.gif
Name : new_018.gif
Size : 9 Ko
Type : Fichier GIF
Date Modified : 30/01/2006 15:56
Date Created : 30/01/2006 15:56
Date Accessed : 13/03/2006 16:37
Attributes : A
Status : Connecté
Owner : chamcham
Title :
Subject :
Category :
Pages :
et voici mon prog, je sent que je suis pas loin mais vue que le VBScript et moi c j'ai un peu de mal.
Set objShell = CreateObject ("Shell.Application")
Set Fso = Wscript.CreateObject("Scripting.FileSystemObject")
Set Afolder = fso.GetFolder("C:\image")
Set objFolder = objShell.Namespace ("C:\image")
Set objFSO = CreateObject("Scripting.FileSystemObject")
SET Rapport = ObjFSO.OpenTextFile("C:\Documents and Settings\Thomas\Desktop\autre.xls",2,TRUE,0)
Dim arrHeaders(13)
Recherche AFolder
Function Recherche (ByRef AFolder)
For i = 0 to 13
arrHeaders(i) = objFolder.GetDetailsOf (objFolder.Items, i)
Next
For Each AFile In AFolder.Files
If UCase(FSO.GetExtensionName(AFile.Path)) = "RPT" Then
Rapport.writeline AFile.path
For i = 0 to 13
If i <> 9 then
Rapport.writeline arrHeaders(i) _
& ": " & objFolder.GetDetailsOf (strFilename, i)
End If
Next
End if
Next
For Each SubF In AFolder.SubFolders
Recherche SubF
Next
End Function