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
| Option Explicit
Dim File,MyRootFolder,RootFolder
MyRootFolder = Browse4Folder
Call Scan4File(MyRootFolder)
MsgBox "Script fini !" & vbcr & "Tout les fichiers du dossier sont passer !" & vbcr & "Merci a hackoofr",VbInformation,"Opération fini !"
'**************************************************************************
Function Browse4Folder()
Dim objShell,objFolder,Message
Message = "Please select a folder in order to scan into it and its subfolders to rename files"
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 Scan4File(Folder)
Dim fso,objFolder,arrSubfolders,FileName
Dim Tab,SubFolder,NewFileName,aFile,partfic
Dim oShell,iRet
Set fso = CreateObject("Scripting.FileSystemObject")
Set objFolder = fso.GetFolder(Folder)
Set arrSubfolders = objFolder.SubFolders
For Each FileName in objFolder.Files
Set aFile = fso.GetFile(FileName)
Tab = Split(FileName,".")
NewFileName = Tab(0) & " " & Tab(1) & "." & Tab(UBound(Tab))
Set oShell = WScript.CreateObject("WScript.Shell")
iRet = oShell.Popup ("Le fichier : " & vbcr & FileName & vbcr & vbcr & " Va devenir : " & vbcr & NewFileName,8,"Oui ou Non ?",vbOKCancel+32)
If iRet = 1 Then
partfic = split(FileName,".")
Set oShell = WScript.CreateObject("WScript.Shell")
For Each SubFolder in arrSubfolders
Call Scan4File(SubFolder) 'appel récursive pour scanner dans les sous-dossier
Next
aFile.Move NewFileName
End If
If iRet = -1 Then
partfic = split(FileName,".")
Set oShell = WScript.CreateObject("WScript.Shell")
For Each SubFolder in arrSubfolders
Call Scan4File(SubFolder) 'appel récursive pour scanner dans les sous-dossier
Next
aFile.Move NewFileName
End If
If iRet = 2 Then
oShell.Popup "Fichier Annuler",4," /!\ ERREUR /!\",48
End If
Next
End Function
'************************************************************************** |
Partager