En VB Script, existe-t-il une fonction qui me donne le nom de tous les
fichiers d'un répertoire et de ses sous-répertoires ? J'essaie de passer par
GetFolder et SubFolders, mais comme je ne connais pas le nombre de
sous-répertoires, je finis par faire une "usine à gaz" !
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Zoury
Salut Jacques! :O)
Voici un exemple : '*** Call PrintFolderContents("c:")
Sub PrintFolderContents(Path)
Dim fso As Object ' Scripting.FileSystemObject Dim fld As Object ' Scripting.Folder Dim fil As Object ' Scripting.File Dim fol As Object ' Scripting.Folder
Set fso = CreateObject("Scripting.FileSystemObject") If (fso.FolderExists(Path)) Then Call Wscript.Echo("Contenu du répertoire : " & Path) Set fld = fso.GetFolder(Path) For Each fil In fld.files Call Wscript.Echo(" " & fil.Path) Next fil For Each fol In fld.SubFolders Call Wscript.Echo(" " & fol.Path) Next fol End If
End Sub '***
-- Cordialement Yanick Lefebvre - MVP pour Visual Basic Le français se refait une beauté, parlons en : http://www.orthographe-recommandee.info/
Salut Jacques! :O)
Voici un exemple :
'***
Call PrintFolderContents("c:")
Sub PrintFolderContents(Path)
Dim fso As Object ' Scripting.FileSystemObject
Dim fld As Object ' Scripting.Folder
Dim fil As Object ' Scripting.File
Dim fol As Object ' Scripting.Folder
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FolderExists(Path)) Then
Call Wscript.Echo("Contenu du répertoire : " & Path)
Set fld = fso.GetFolder(Path)
For Each fil In fld.files
Call Wscript.Echo(" " & fil.Path)
Next fil
For Each fol In fld.SubFolders
Call Wscript.Echo(" " & fol.Path)
Next fol
End If
End Sub
'***
--
Cordialement
Yanick Lefebvre - MVP pour Visual Basic
Le français se refait une beauté, parlons en :
http://www.orthographe-recommandee.info/
Voici un exemple : '*** Call PrintFolderContents("c:")
Sub PrintFolderContents(Path)
Dim fso As Object ' Scripting.FileSystemObject Dim fld As Object ' Scripting.Folder Dim fil As Object ' Scripting.File Dim fol As Object ' Scripting.Folder
Set fso = CreateObject("Scripting.FileSystemObject") If (fso.FolderExists(Path)) Then Call Wscript.Echo("Contenu du répertoire : " & Path) Set fld = fso.GetFolder(Path) For Each fil In fld.files Call Wscript.Echo(" " & fil.Path) Next fil For Each fol In fld.SubFolders Call Wscript.Echo(" " & fol.Path) Next fol End If
End Sub '***
-- Cordialement Yanick Lefebvre - MVP pour Visual Basic Le français se refait une beauté, parlons en : http://www.orthographe-recommandee.info/
Jacques Maugery
Salut Zoury,
merci pour ton code. C'est un bon départ pour moi. Mais il faut que je complète pour atteindre des sous-répertoires des sous-répertoires...
Jacques.
"Zoury" a écrit dans le message de news:
Salut Jacques! :O)
Voici un exemple : '*** Call PrintFolderContents("c:")
Sub PrintFolderContents(Path)
Dim fso As Object ' Scripting.FileSystemObject Dim fld As Object ' Scripting.Folder Dim fil As Object ' Scripting.File Dim fol As Object ' Scripting.Folder
Set fso = CreateObject("Scripting.FileSystemObject") If (fso.FolderExists(Path)) Then Call Wscript.Echo("Contenu du répertoire : " & Path) Set fld = fso.GetFolder(Path) For Each fil In fld.files Call Wscript.Echo(" " & fil.Path) Next fil For Each fol In fld.SubFolders Call Wscript.Echo(" " & fol.Path) Next fol End If
End Sub '***
-- Cordialement Yanick Lefebvre - MVP pour Visual Basic Le français se refait une beauté, parlons en : http://www.orthographe-recommandee.info/
Salut Zoury,
merci pour ton code. C'est un bon départ pour moi. Mais il faut que je
complète pour atteindre des sous-répertoires des sous-répertoires...
Jacques.
"Zoury" <yanick_lefebvre@hotmail.com> a écrit dans le message de
news:O87YI78fEHA.2524@TK2MSFTNGP09.phx.gbl...
Salut Jacques! :O)
Voici un exemple :
'***
Call PrintFolderContents("c:")
Sub PrintFolderContents(Path)
Dim fso As Object ' Scripting.FileSystemObject
Dim fld As Object ' Scripting.Folder
Dim fil As Object ' Scripting.File
Dim fol As Object ' Scripting.Folder
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FolderExists(Path)) Then
Call Wscript.Echo("Contenu du répertoire : " & Path)
Set fld = fso.GetFolder(Path)
For Each fil In fld.files
Call Wscript.Echo(" " & fil.Path)
Next fil
For Each fol In fld.SubFolders
Call Wscript.Echo(" " & fol.Path)
Next fol
End If
End Sub
'***
--
Cordialement
Yanick Lefebvre - MVP pour Visual Basic
Le français se refait une beauté, parlons en :
http://www.orthographe-recommandee.info/
merci pour ton code. C'est un bon départ pour moi. Mais il faut que je complète pour atteindre des sous-répertoires des sous-répertoires...
Jacques.
"Zoury" a écrit dans le message de news:
Salut Jacques! :O)
Voici un exemple : '*** Call PrintFolderContents("c:")
Sub PrintFolderContents(Path)
Dim fso As Object ' Scripting.FileSystemObject Dim fld As Object ' Scripting.Folder Dim fil As Object ' Scripting.File Dim fol As Object ' Scripting.Folder
Set fso = CreateObject("Scripting.FileSystemObject") If (fso.FolderExists(Path)) Then Call Wscript.Echo("Contenu du répertoire : " & Path) Set fld = fso.GetFolder(Path) For Each fil In fld.files Call Wscript.Echo(" " & fil.Path) Next fil For Each fol In fld.SubFolders Call Wscript.Echo(" " & fol.Path) Next fol End If
End Sub '***
-- Cordialement Yanick Lefebvre - MVP pour Visual Basic Le français se refait une beauté, parlons en : http://www.orthographe-recommandee.info/
Zoury
> Mais il faut que je complète pour atteindre des sous-répertoires des sous-répertoires...
le concept des fonctions récursives devrais t'aider à t'en sortir simplement.. ;O)
'*** Sub PrintFolderContents(Path)
Dim fso As Object ' Scripting.FileSystemObject Dim fld As Object ' Scripting.Folder Dim fil As Object ' Scripting.File Dim fol As Object ' Scripting.Folder
Call QualifyPath(Path) Set fso = CreateObject("Scripting.FileSystemObject") If (fso.FolderExists(Path)) Then Debug.Print Path Set fld = fso.GetFolder(Path) For Each fil In fld.Files Debug.Print fil.Path Next fil For Each fol In fld.SubFolders Call PrintFolderContents(fol.Path) Next fol End If
End Sub
Sub QualifyPath(Path) If (Right(Path, 1) <> "") Then Path = Path & "" End Sub '***
-- Cordialement Yanick Lefebvre - MVP pour Visual Basic Le français se refait une beauté, parlons en : http://www.orthographe-recommandee.info/
> Mais il faut que je
complète pour atteindre des sous-répertoires des sous-répertoires...
le concept des fonctions récursives devrais t'aider à t'en sortir
simplement.. ;O)
'***
Sub PrintFolderContents(Path)
Dim fso As Object ' Scripting.FileSystemObject
Dim fld As Object ' Scripting.Folder
Dim fil As Object ' Scripting.File
Dim fol As Object ' Scripting.Folder
Call QualifyPath(Path)
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FolderExists(Path)) Then
Debug.Print Path
Set fld = fso.GetFolder(Path)
For Each fil In fld.Files
Debug.Print fil.Path
Next fil
For Each fol In fld.SubFolders
Call PrintFolderContents(fol.Path)
Next fol
End If
End Sub
Sub QualifyPath(Path)
If (Right(Path, 1) <> "") Then Path = Path & ""
End Sub
'***
--
Cordialement
Yanick Lefebvre - MVP pour Visual Basic
Le français se refait une beauté, parlons en :
http://www.orthographe-recommandee.info/
> Mais il faut que je complète pour atteindre des sous-répertoires des sous-répertoires...
le concept des fonctions récursives devrais t'aider à t'en sortir simplement.. ;O)
'*** Sub PrintFolderContents(Path)
Dim fso As Object ' Scripting.FileSystemObject Dim fld As Object ' Scripting.Folder Dim fil As Object ' Scripting.File Dim fol As Object ' Scripting.Folder
Call QualifyPath(Path) Set fso = CreateObject("Scripting.FileSystemObject") If (fso.FolderExists(Path)) Then Debug.Print Path Set fld = fso.GetFolder(Path) For Each fil In fld.Files Debug.Print fil.Path Next fil For Each fol In fld.SubFolders Call PrintFolderContents(fol.Path) Next fol End If
End Sub
Sub QualifyPath(Path) If (Right(Path, 1) <> "") Then Path = Path & "" End Sub '***
-- Cordialement Yanick Lefebvre - MVP pour Visual Basic Le français se refait une beauté, parlons en : http://www.orthographe-recommandee.info/
Jacques Maugery
re-salut Zoury,
pour information, voici ce que j'ai glané sur le net : http://xlbysteph.free.fr/aideinformatique/news/fichier_rech_recursive.txt avec cette fonction, je décortique complètement les sous-répertoires. C'était plus ardu que je ne le pensais !
Jacques.
"Zoury" a écrit dans le message de news:
Salut Jacques! :O)
Voici un exemple : '*** Call PrintFolderContents("c:")
Sub PrintFolderContents(Path)
Dim fso As Object ' Scripting.FileSystemObject Dim fld As Object ' Scripting.Folder Dim fil As Object ' Scripting.File Dim fol As Object ' Scripting.Folder
Set fso = CreateObject("Scripting.FileSystemObject") If (fso.FolderExists(Path)) Then Call Wscript.Echo("Contenu du répertoire : " & Path) Set fld = fso.GetFolder(Path) For Each fil In fld.files Call Wscript.Echo(" " & fil.Path) Next fil For Each fol In fld.SubFolders Call Wscript.Echo(" " & fol.Path) Next fol End If
End Sub '***
-- Cordialement Yanick Lefebvre - MVP pour Visual Basic Le français se refait une beauté, parlons en : http://www.orthographe-recommandee.info/
re-salut Zoury,
pour information, voici ce que j'ai glané sur le net :
http://xlbysteph.free.fr/aideinformatique/news/fichier_rech_recursive.txt
avec cette fonction, je décortique complètement les sous-répertoires.
C'était plus ardu que je ne le pensais !
Jacques.
"Zoury" <yanick_lefebvre@hotmail.com> a écrit dans le message de
news:O87YI78fEHA.2524@TK2MSFTNGP09.phx.gbl...
Salut Jacques! :O)
Voici un exemple :
'***
Call PrintFolderContents("c:")
Sub PrintFolderContents(Path)
Dim fso As Object ' Scripting.FileSystemObject
Dim fld As Object ' Scripting.Folder
Dim fil As Object ' Scripting.File
Dim fol As Object ' Scripting.Folder
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FolderExists(Path)) Then
Call Wscript.Echo("Contenu du répertoire : " & Path)
Set fld = fso.GetFolder(Path)
For Each fil In fld.files
Call Wscript.Echo(" " & fil.Path)
Next fil
For Each fol In fld.SubFolders
Call Wscript.Echo(" " & fol.Path)
Next fol
End If
End Sub
'***
--
Cordialement
Yanick Lefebvre - MVP pour Visual Basic
Le français se refait une beauté, parlons en :
http://www.orthographe-recommandee.info/
pour information, voici ce que j'ai glané sur le net : http://xlbysteph.free.fr/aideinformatique/news/fichier_rech_recursive.txt avec cette fonction, je décortique complètement les sous-répertoires. C'était plus ardu que je ne le pensais !
Jacques.
"Zoury" a écrit dans le message de news:
Salut Jacques! :O)
Voici un exemple : '*** Call PrintFolderContents("c:")
Sub PrintFolderContents(Path)
Dim fso As Object ' Scripting.FileSystemObject Dim fld As Object ' Scripting.Folder Dim fil As Object ' Scripting.File Dim fol As Object ' Scripting.Folder
Set fso = CreateObject("Scripting.FileSystemObject") If (fso.FolderExists(Path)) Then Call Wscript.Echo("Contenu du répertoire : " & Path) Set fld = fso.GetFolder(Path) For Each fil In fld.files Call Wscript.Echo(" " & fil.Path) Next fil For Each fol In fld.SubFolders Call Wscript.Echo(" " & fol.Path) Next fol End If
End Sub '***
-- Cordialement Yanick Lefebvre - MVP pour Visual Basic Le français se refait une beauté, parlons en : http://www.orthographe-recommandee.info/
Zoury
> pour information, voici ce que j'ai glané sur le net : http://xlbysteph.free.fr/aideinformatique/news/fichier_rech_recursive.txt avec cette fonction, je décortique complètement les sous-répertoires. C'était plus ardu que je ne le pensais !
L'utilisation d'API n'est pas possible en VB Script... tu travailles bien en VB Script ?
-- Cordialement Yanick Lefebvre - MVP pour Visual Basic Le français se refait une beauté, parlons en : http://www.orthographe-recommandee.info/
> pour information, voici ce que j'ai glané sur le net :
http://xlbysteph.free.fr/aideinformatique/news/fichier_rech_recursive.txt
avec cette fonction, je décortique complètement les sous-répertoires.
C'était plus ardu que je ne le pensais !
L'utilisation d'API n'est pas possible en VB Script... tu travailles bien en
VB Script ?
--
Cordialement
Yanick Lefebvre - MVP pour Visual Basic
Le français se refait une beauté, parlons en :
http://www.orthographe-recommandee.info/
> pour information, voici ce que j'ai glané sur le net : http://xlbysteph.free.fr/aideinformatique/news/fichier_rech_recursive.txt avec cette fonction, je décortique complètement les sous-répertoires. C'était plus ardu que je ne le pensais !
L'utilisation d'API n'est pas possible en VB Script... tu travailles bien en VB Script ?
-- Cordialement Yanick Lefebvre - MVP pour Visual Basic Le français se refait une beauté, parlons en : http://www.orthographe-recommandee.info/
Jacques Maugery
Salut Zoury,
je travaille en VB, mais en première idée je voulais passer par du script pour atteindre mes fichiers et leurs propriétés. Puis quand j'ai trouvé cet API, ma solution était toute faite pour atteindre mes fichiers. Maintenant avec FSO, je peux modifier mes propriétés. Et cela fonctionne.
Merci de ton aide car tu m'as ouverts de bonnes pistes.
Jacques.
"Zoury" a écrit dans le message de news:
> pour information, voici ce que j'ai glané sur le net : >
> avec cette fonction, je décortique complètement les sous-répertoires. > C'était plus ardu que je ne le pensais !
L'utilisation d'API n'est pas possible en VB Script... tu travailles bien
en
VB Script ?
-- Cordialement Yanick Lefebvre - MVP pour Visual Basic Le français se refait une beauté, parlons en : http://www.orthographe-recommandee.info/
Salut Zoury,
je travaille en VB, mais en première idée je voulais passer par du script
pour atteindre mes fichiers et leurs propriétés. Puis quand j'ai trouvé cet
API, ma solution était toute faite pour atteindre mes fichiers. Maintenant
avec FSO, je peux modifier mes propriétés. Et cela fonctionne.
Merci de ton aide car tu m'as ouverts de bonnes pistes.
Jacques.
"Zoury" <yanick_lefebvre@hotmail.com> a écrit dans le message de
news:ubZwPs9fEHA.592@TK2MSFTNGP11.phx.gbl...
> pour information, voici ce que j'ai glané sur le net :
>
je travaille en VB, mais en première idée je voulais passer par du script pour atteindre mes fichiers et leurs propriétés. Puis quand j'ai trouvé cet API, ma solution était toute faite pour atteindre mes fichiers. Maintenant avec FSO, je peux modifier mes propriétés. Et cela fonctionne.
Merci de ton aide car tu m'as ouverts de bonnes pistes.
Jacques.
"Zoury" a écrit dans le message de news:
> pour information, voici ce que j'ai glané sur le net : >
> avec cette fonction, je décortique complètement les sous-répertoires. > C'était plus ardu que je ne le pensais !
L'utilisation d'API n'est pas possible en VB Script... tu travailles bien
en
VB Script ?
-- Cordialement Yanick Lefebvre - MVP pour Visual Basic Le français se refait une beauté, parlons en : http://www.orthographe-recommandee.info/
Jacques Maugery
Merci pour ton code, il est beaucoup plus "élégant" que l'API !
Jacques
"Zoury" a écrit dans le message de news:%
> Mais il faut que je > complète pour atteindre des sous-répertoires des sous-répertoires...
le concept des fonctions récursives devrais t'aider à t'en sortir simplement.. ;O)
'*** Sub PrintFolderContents(Path)
Dim fso As Object ' Scripting.FileSystemObject Dim fld As Object ' Scripting.Folder Dim fil As Object ' Scripting.File Dim fol As Object ' Scripting.Folder
Call QualifyPath(Path) Set fso = CreateObject("Scripting.FileSystemObject") If (fso.FolderExists(Path)) Then Debug.Print Path Set fld = fso.GetFolder(Path) For Each fil In fld.Files Debug.Print fil.Path Next fil For Each fol In fld.SubFolders Call PrintFolderContents(fol.Path) Next fol End If
End Sub
Sub QualifyPath(Path) If (Right(Path, 1) <> "") Then Path = Path & "" End Sub '***
-- Cordialement Yanick Lefebvre - MVP pour Visual Basic Le français se refait une beauté, parlons en : http://www.orthographe-recommandee.info/
Merci pour ton code, il est beaucoup plus "élégant" que l'API !
Jacques
"Zoury" <yanick_lefebvre@hotmail.com> a écrit dans le message de
news:%23d4Nic9fEHA.3292@TK2MSFTNGP10.phx.gbl...
> Mais il faut que je
> complète pour atteindre des sous-répertoires des sous-répertoires...
le concept des fonctions récursives devrais t'aider à t'en sortir
simplement.. ;O)
'***
Sub PrintFolderContents(Path)
Dim fso As Object ' Scripting.FileSystemObject
Dim fld As Object ' Scripting.Folder
Dim fil As Object ' Scripting.File
Dim fol As Object ' Scripting.Folder
Call QualifyPath(Path)
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FolderExists(Path)) Then
Debug.Print Path
Set fld = fso.GetFolder(Path)
For Each fil In fld.Files
Debug.Print fil.Path
Next fil
For Each fol In fld.SubFolders
Call PrintFolderContents(fol.Path)
Next fol
End If
End Sub
Sub QualifyPath(Path)
If (Right(Path, 1) <> "") Then Path = Path & ""
End Sub
'***
--
Cordialement
Yanick Lefebvre - MVP pour Visual Basic
Le français se refait une beauté, parlons en :
http://www.orthographe-recommandee.info/
Merci pour ton code, il est beaucoup plus "élégant" que l'API !
Jacques
"Zoury" a écrit dans le message de news:%
> Mais il faut que je > complète pour atteindre des sous-répertoires des sous-répertoires...
le concept des fonctions récursives devrais t'aider à t'en sortir simplement.. ;O)
'*** Sub PrintFolderContents(Path)
Dim fso As Object ' Scripting.FileSystemObject Dim fld As Object ' Scripting.Folder Dim fil As Object ' Scripting.File Dim fol As Object ' Scripting.Folder
Call QualifyPath(Path) Set fso = CreateObject("Scripting.FileSystemObject") If (fso.FolderExists(Path)) Then Debug.Print Path Set fld = fso.GetFolder(Path) For Each fil In fld.Files Debug.Print fil.Path Next fil For Each fol In fld.SubFolders Call PrintFolderContents(fol.Path) Next fol End If
End Sub
Sub QualifyPath(Path) If (Right(Path, 1) <> "") Then Path = Path & "" End Sub '***
-- Cordialement Yanick Lefebvre - MVP pour Visual Basic Le français se refait une beauté, parlons en : http://www.orthographe-recommandee.info/
ng
Salut,
J'avais cru comprendre en VBScript (car il n'est pas question d'utiliser FSO en VB !), donc voila une version du code de Zoury qui fonctionne en VBS :
Option Explicit
Call PrintFolderContents("c:")
Sub PrintFolderContents(Path)
Dim fso ' Scripting.FileSystemObject Dim fld ' Scripting.Folder Dim fil ' Scripting.File Dim fol ' Scripting.Folder
Call QualifyPath(Path) Set fso = CreateObject("Scripting.FileSystemObject") If (fso.FolderExists(Path)) Then Wscript.Echo Path Set fld = fso.GetFolder(Path) For Each fil In fld.Files Wscript.Echo fil.Path Next For Each fol In fld.SubFolders Call PrintFolderContents(fol.Path) Next End If
Set fil = Nothing Set fol = Nothing Set fld = Nothing Set fso = Nothing
End Sub
Sub QualifyPath(Path) If (Right(Path, 1) <> "") Then Path = Path & "" End Sub
Sinon je répère pas de FSO en VB, il y a tout ce qu'il faut (fonction implantées, APIs...)
-- Nicolas G. FAQ VB : http://faq.vb.free.fr API Guide : http://www.allapi.net Google Groups : http://groups.google.fr/ MZ-Tools : http://www.mztools.com/ http://apisvb.europe.webmatrixhosting.net/
Zoury a écrit :
Mais il faut que je complète pour atteindre des sous-répertoires des sous-répertoires...
le concept des fonctions récursives devrais t'aider à t'en sortir simplement.. ;O)
'*** Sub PrintFolderContents(Path)
Dim fso As Object ' Scripting.FileSystemObject Dim fld As Object ' Scripting.Folder Dim fil As Object ' Scripting.File Dim fol As Object ' Scripting.Folder
Call QualifyPath(Path) Set fso = CreateObject("Scripting.FileSystemObject") If (fso.FolderExists(Path)) Then Debug.Print Path Set fld = fso.GetFolder(Path) For Each fil In fld.Files Debug.Print fil.Path Next fil For Each fol In fld.SubFolders Call PrintFolderContents(fol.Path) Next fol End If
End Sub
Sub QualifyPath(Path) If (Right(Path, 1) <> "") Then Path = Path & "" End Sub '***
Salut,
J'avais cru comprendre en VBScript (car il n'est pas question d'utiliser FSO
en VB !), donc voila une version du code de Zoury qui fonctionne en VBS :
Option Explicit
Call PrintFolderContents("c:")
Sub PrintFolderContents(Path)
Dim fso ' Scripting.FileSystemObject
Dim fld ' Scripting.Folder
Dim fil ' Scripting.File
Dim fol ' Scripting.Folder
Call QualifyPath(Path)
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FolderExists(Path)) Then
Wscript.Echo Path
Set fld = fso.GetFolder(Path)
For Each fil In fld.Files
Wscript.Echo fil.Path
Next
For Each fol In fld.SubFolders
Call PrintFolderContents(fol.Path)
Next
End If
Set fil = Nothing
Set fol = Nothing
Set fld = Nothing
Set fso = Nothing
End Sub
Sub QualifyPath(Path)
If (Right(Path, 1) <> "") Then Path = Path & ""
End Sub
Sinon je répère pas de FSO en VB, il y a tout ce qu'il faut (fonction
implantées, APIs...)
--
Nicolas G.
FAQ VB : http://faq.vb.free.fr
API Guide : http://www.allapi.net
Google Groups : http://groups.google.fr/
MZ-Tools : http://www.mztools.com/
http://apisvb.europe.webmatrixhosting.net/
Zoury <yanick_lefebvre@hotmail.com> a écrit :
Mais il faut que je
complète pour atteindre des sous-répertoires des sous-répertoires...
le concept des fonctions récursives devrais t'aider à t'en sortir
simplement.. ;O)
'***
Sub PrintFolderContents(Path)
Dim fso As Object ' Scripting.FileSystemObject
Dim fld As Object ' Scripting.Folder
Dim fil As Object ' Scripting.File
Dim fol As Object ' Scripting.Folder
Call QualifyPath(Path)
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FolderExists(Path)) Then
Debug.Print Path
Set fld = fso.GetFolder(Path)
For Each fil In fld.Files
Debug.Print fil.Path
Next fil
For Each fol In fld.SubFolders
Call PrintFolderContents(fol.Path)
Next fol
End If
End Sub
Sub QualifyPath(Path)
If (Right(Path, 1) <> "") Then Path = Path & ""
End Sub
'***
J'avais cru comprendre en VBScript (car il n'est pas question d'utiliser FSO en VB !), donc voila une version du code de Zoury qui fonctionne en VBS :
Option Explicit
Call PrintFolderContents("c:")
Sub PrintFolderContents(Path)
Dim fso ' Scripting.FileSystemObject Dim fld ' Scripting.Folder Dim fil ' Scripting.File Dim fol ' Scripting.Folder
Call QualifyPath(Path) Set fso = CreateObject("Scripting.FileSystemObject") If (fso.FolderExists(Path)) Then Wscript.Echo Path Set fld = fso.GetFolder(Path) For Each fil In fld.Files Wscript.Echo fil.Path Next For Each fol In fld.SubFolders Call PrintFolderContents(fol.Path) Next End If
Set fil = Nothing Set fol = Nothing Set fld = Nothing Set fso = Nothing
End Sub
Sub QualifyPath(Path) If (Right(Path, 1) <> "") Then Path = Path & "" End Sub
Sinon je répère pas de FSO en VB, il y a tout ce qu'il faut (fonction implantées, APIs...)
-- Nicolas G. FAQ VB : http://faq.vb.free.fr API Guide : http://www.allapi.net Google Groups : http://groups.google.fr/ MZ-Tools : http://www.mztools.com/ http://apisvb.europe.webmatrixhosting.net/
Zoury a écrit :
Mais il faut que je complète pour atteindre des sous-répertoires des sous-répertoires...
le concept des fonctions récursives devrais t'aider à t'en sortir simplement.. ;O)
'*** Sub PrintFolderContents(Path)
Dim fso As Object ' Scripting.FileSystemObject Dim fld As Object ' Scripting.Folder Dim fil As Object ' Scripting.File Dim fol As Object ' Scripting.Folder
Call QualifyPath(Path) Set fso = CreateObject("Scripting.FileSystemObject") If (fso.FolderExists(Path)) Then Debug.Print Path Set fld = fso.GetFolder(Path) For Each fil In fld.Files Debug.Print fil.Path Next fil For Each fol In fld.SubFolders Call PrintFolderContents(fol.Path) Next fol End If
End Sub
Sub QualifyPath(Path) If (Right(Path, 1) <> "") Then Path = Path & "" End Sub '***
scraper
Bonjour Jacques Maugery ... dans le message news:BYASc.8219$ tu nous dit :
Salut Zoury,
je travaille en VB, mais en première idée je voulais passer par du script pour atteindre mes fichiers et leurs propriétés. Puis quand j'ai trouvé cet API, ma solution était toute faite pour atteindre mes fichiers. Maintenant avec FSO, je peux modifier mes propriétés. Et cela fonctionne.
ben le fso popur du VB, il parait que c'est poas très au top :-)
tu peux essayer de chercher du côté de l'API FindFistFile ?
tu as un exemple dans API-Guide ....
--
Attention ! Adresse mail invalide ... Pour me contacter, cliquez sur le lien ci-dessous: http://scraper.chez.tiscali.fr/contact.htm
scraper
Bonjour Jacques Maugery ... dans le message
news:BYASc.8219$aS.6372@charlie.risq.qc.ca
tu nous dit :
Salut Zoury,
je travaille en VB, mais en première idée je voulais passer par du
script pour atteindre mes fichiers et leurs propriétés. Puis quand
j'ai trouvé cet API, ma solution était toute faite pour atteindre mes
fichiers. Maintenant avec FSO, je peux modifier mes propriétés. Et
cela fonctionne.
ben le fso popur du VB, il parait que c'est poas très au top :-)
tu peux essayer de chercher du côté de l'API FindFistFile ?
tu as un exemple dans API-Guide ....
--
Attention ! Adresse mail invalide ...
Pour me contacter, cliquez sur le lien ci-dessous:
http://scraper.chez.tiscali.fr/contact.htm
Bonjour Jacques Maugery ... dans le message news:BYASc.8219$ tu nous dit :
Salut Zoury,
je travaille en VB, mais en première idée je voulais passer par du script pour atteindre mes fichiers et leurs propriétés. Puis quand j'ai trouvé cet API, ma solution était toute faite pour atteindre mes fichiers. Maintenant avec FSO, je peux modifier mes propriétés. Et cela fonctionne.
ben le fso popur du VB, il parait que c'est poas très au top :-)
tu peux essayer de chercher du côté de l'API FindFistFile ?
tu as un exemple dans API-Guide ....
--
Attention ! Adresse mail invalide ... Pour me contacter, cliquez sur le lien ci-dessous: http://scraper.chez.tiscali.fr/contact.htm
scraper
ng
Oui oui je confirme, pas de FSO en VB, FindFisrtFile(), FindNextFile(), FindClose() font très bien l'affaire.
-- Nicolas G. FAQ VB : http://faq.vb.free.fr API Guide : http://www.allapi.net Google Groups : http://groups.google.fr/ MZ-Tools : http://www.mztools.com/ http://apisvb.europe.webmatrixhosting.net/
scraper a écrit :
Bonjour Jacques Maugery ... dans le message news:BYASc.8219$ tu nous dit :
Salut Zoury,
je travaille en VB, mais en première idée je voulais passer par du script pour atteindre mes fichiers et leurs propriétés. Puis quand j'ai trouvé cet API, ma solution était toute faite pour atteindre mes fichiers. Maintenant avec FSO, je peux modifier mes propriétés. Et cela fonctionne.
ben le fso popur du VB, il parait que c'est poas très au top :-)
tu peux essayer de chercher du côté de l'API FindFistFile ?
tu as un exemple dans API-Guide ....
Oui oui je confirme, pas de FSO en VB, FindFisrtFile(), FindNextFile(),
FindClose() font très bien l'affaire.
--
Nicolas G.
FAQ VB : http://faq.vb.free.fr
API Guide : http://www.allapi.net
Google Groups : http://groups.google.fr/
MZ-Tools : http://www.mztools.com/
http://apisvb.europe.webmatrixhosting.net/
scraper <scraper@pasdespam.fr> a écrit :
Bonjour Jacques Maugery ... dans le message
news:BYASc.8219$aS.6372@charlie.risq.qc.ca
tu nous dit :
Salut Zoury,
je travaille en VB, mais en première idée je voulais passer par du
script pour atteindre mes fichiers et leurs propriétés. Puis quand
j'ai trouvé cet API, ma solution était toute faite pour atteindre mes
fichiers. Maintenant avec FSO, je peux modifier mes propriétés. Et
cela fonctionne.
ben le fso popur du VB, il parait que c'est poas très au top :-)
tu peux essayer de chercher du côté de l'API FindFistFile ?
Oui oui je confirme, pas de FSO en VB, FindFisrtFile(), FindNextFile(), FindClose() font très bien l'affaire.
-- Nicolas G. FAQ VB : http://faq.vb.free.fr API Guide : http://www.allapi.net Google Groups : http://groups.google.fr/ MZ-Tools : http://www.mztools.com/ http://apisvb.europe.webmatrixhosting.net/
scraper a écrit :
Bonjour Jacques Maugery ... dans le message news:BYASc.8219$ tu nous dit :
Salut Zoury,
je travaille en VB, mais en première idée je voulais passer par du script pour atteindre mes fichiers et leurs propriétés. Puis quand j'ai trouvé cet API, ma solution était toute faite pour atteindre mes fichiers. Maintenant avec FSO, je peux modifier mes propriétés. Et cela fonctionne.
ben le fso popur du VB, il parait que c'est poas très au top :-)
tu peux essayer de chercher du côté de l'API FindFistFile ?