IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VBScript Discussion :

Création de chemin à partir d'un point spécifique


Sujet :

VBScript

  1. #1
    Nouveau membre du Club
    Homme Profil pro
    Géologue
    Inscrit en
    Septembre 2011
    Messages
    37
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 64
    Localisation : Niger

    Informations professionnelles :
    Activité : Géologue
    Secteur : Industrie

    Informations forums :
    Inscription : Septembre 2011
    Messages : 37
    Points : 27
    Points
    27
    Par défaut Création de chemin à partir d'un point spécifique
    Bonjour,

    Le petit script ci-dessous, en développement, fonctionne correctement et me trouve les répertoires LAS20 qui peuvent être à une "distance" variable de la racine.

    L'arborescence étant du type : C:\a\...\c\répertoire ou la chaine C:\a\...\c peut être variable.

    Répertoire contient deux sous répertoires : "Données brutes" et "Données traitées". Le répertoire LAS20 cible de la recherche de départ se trouve dans "Donnée brutes".

    Je voudrais construire les chemins (ligne 68 et suivante(s)) , utilisable dans d'autre sous programmes (à écrire) pour enregistrer des fichiers dans "Données brutes" et dans "Données traités".

    Comment faire pour construire ces chemins? ... Je n'y arrive pas.

    Si je peux avoir de l'aide je vous en remercie d'avance,

    Bon WE de pâque à tous

    Michel

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
     'Get Application object of the Windows shell.
    	Set objShell = WScript.CreateObject("Shell.Application")
     
    'Get access to script folder and create the resulting file in it
    	Set FSO = CreateObject("Scripting.FileSystemObject")
    	PATH = FSO.GetParentFolderName(wscript.ScriptFullName) & "\"
     
    'Ask the user to select a folder
    	Set obFolder = objShell.BrowseForFolder (&H0&, "Select the folder to process", &H1&)
    	'Keep obFolder for sub programms
    	Set obFolder2 = obFolder
     
    If Not obfolder IS Nothing Then 'si obfolder n'est pas rien!
     
    'Corps du script
     
    'Start WellCAD
    	Set WCAD = CreateObject("WellCAD.Application")
    	WCAD.ShowWindow()
     
    'Get access to input folder and process it
     
    	'Crée la variable PATH comme étant le chemin du répertoire du script
    	PATH = FSO.GetParentFolderName(wscript.ScriptFullName) & "\"
     
    	'wscript.echo "Path = " & PATH
     
    	'Appel le sous programme Processfolder
    	Processfolder WCAD, FSO, PATH, obFolder.self.Path
     
     
    	MsgBox "Finished"
     
    Else
     
    	MsgBox "Canceled"
     
    End If
     
     
    'Sous Programme process folder
    Sub ProcessFolder(WCAD, FSO, PATH, FolderPath)
     
    	'Get access to the folder
    	Set obFolder = FSO.GetFolder(FolderPath)
     
    	'Loop on all the files and process each of them
    	For Each obFile In obFolder.Files
     
    		'Regarde si fichiers présent dans le répertoire
    		If (StrComp(Right(obFile.Name, 3), "las", 1) = 0) Then ProcessLasFiles WCAD, FSO, FolderPath
    		Exit For
    		'End If
     
    	Next
     
    	'Loop on all the subfolders and process each of them
    	For Each obSubFolder In obFolder.SubFolders
    		ProcessFolder WCAD, FSO, PATH,  obSubFolder.Path
    	Next
     
    End Sub
     
    Sub ProcessLasFiles (WCAD, FSO, FolderPath)
     
    	Wscript.echo "Trouvé fichier LAS"
    	Set obSubFolder = FSO.GetFolder(FolderPath)
     
    	Wscript.echo "obSubFolder = " & obSubFolder 'contient bien le bon chemin
     
     
    End Sub

  2. #2
    Nouveau membre du Club
    Homme Profil pro
    Géologue
    Inscrit en
    Septembre 2011
    Messages
    37
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 64
    Localisation : Niger

    Informations professionnelles :
    Activité : Géologue
    Secteur : Industrie

    Informations forums :
    Inscription : Septembre 2011
    Messages : 37
    Points : 27
    Points
    27
    Par défaut Trouvé
    Bonjour,

    C'était trivial et j'ai fini par trouver, je ne met que le code du SUB :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    Sub ProcessLasFiles (WCAD, FSO, FolderPath)
     
    	Wscript.echo "Trouvé fichier LAS"
    	'Set obSubFolder = FSO.GetFolder(FolderPath)
    	ChDB = FSO.GetParentFolderName(obFolder) & "\"
    	Wscript.echo "Chemin Données Brutes = : " & ChDB 'OK ChDB contient le bon chemin
    	ChDT = ChDB & "Données Traitées\"
    	Wscript.echo "Ch DT = " & ChDT
     
    End Sub

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 2
    Dernier message: 29/04/2013, 11h42
  2. Réponses: 3
    Dernier message: 17/09/2012, 13h16
  3. Création JTree cliquable à partir d'une ArrayList de chemins
    Par cedy-kassy dans le forum Collection et Stream
    Réponses: 2
    Dernier message: 16/07/2012, 11h50
  4. Réponses: 4
    Dernier message: 10/12/2011, 19h48

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo