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
| Option Explicit
Dim Dossier,SourceFolder,DestinationFolder,Ws
SourceFolder = Browse4Folder()
DestinationFolder = SourceFolder
Call Scan4Folder(SourceFolder)
MsgBox "Le script est terminé by Hackoo !",VbInformation,"Script est terminé by Hackoo !"
Set Ws = CreateObject("wscript.shell")
ws.run "Explorer " & DblQuote(DestinationFolder)
'**************************************************************************
Function Browse4Folder()
Dim objShell,objFolder,Message
Message = "Please select a folder "
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder(0,Message,0,0)
If objFolder Is Nothing Then
Wscript.Quit
End If
Browse4Folder = objFolder.self.path
End Function
'*********************************************************************
Function Scan4Folder(Folder)
Dim fso,objFolder,Dossier
Dim Tab,LeDossier,NewFolderName
Set fso = CreateObject("Scripting.FileSystemObject")
Set objFolder = fso.GetFolder(Folder)
For Each Dossier in objFolder.SubFolders
Tab = Split(Dossier.Name,"_")
NewFolderName = Tab(0)
BuildFullPath(DestinationFolder & "\" & NewFolderName)
Set LeDossier = fso.GetFolder(Dossier)
LeDossier.Move DestinationFolder & "\" & NewFolderName & "\"
Msgbox "Le dossier " & DblQuote(Dossier) & " est déplacé dans " & vbcr &_
DblQuote(DestinationFolder & "\" & NewFolderName),vbInformation,DblQuote(Dossier)
Next
End Function
'*********************************************************************
Sub BuildFullPath(ByVal FullPath)
Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FolderExists(FullPath) Then
BuildFullPath fso.GetParentFolderName(FullPath)
fso.CreateFolder FullPath
End If
End Sub
'*********************************************************************
Function DblQuote(Str)
DblQuote = Chr(34) & Str & Chr(34)
End Function
'********************************************************************* |
Partager