Guest User

renomeia arquivos e pastas para maiusculo

a guest
Oct 22nd, 2011
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @echo off
  2. (
  3. Echo. Option Explicit
  4. Echo. Dim StdIn:  Set StdIn = WScript.StdIn
  5. Echo. Dim StdOut: Set StdOut = WScript.StdOut
  6. Echo. Dim fso:    Set fso = CreateObject("Scripting.FileSystemObject"^)
  7. Echo. Dim FilesRenamed:   FilesRenamed = 0
  8. Echo. Dim FilesSkipped:   FilesSkipped = 0
  9. Echo. Dim FoldersRenamed: FoldersRenamed = 0
  10. Echo. Dim FoldersSkipped: FoldersSkipped = 0
  11. Echo. Main
  12. Echo. Sub Main
  13. Echo. Dim CurrentFolder: Set CurrentFolder = fso.GetFolder("."^)
  14. Echo. StdOut.WriteLine "Atenção: Todos os arquivos e subdiretórios dentro desse diretório"
  15. Echo. StdOut.WriteLine CurrentFolder.Path
  16. Echo. StdOut.WriteLine "E subdiretórios será renomeado para maiúsculas."
  17. Echo. If Not PromptYesNo("Continuar ?"^) Then Exit Sub
  18. Echo. ProcessFolder CurrentFolder
  19. Echo. StdOut.WriteLine FilesRenamed ^& " Arquivos e " ^& FoldersRenamed ^& " Pastas renomeadas para maiúsculas."
  20. Echo. StdOut.WriteLine FilesSkipped ^& " Arquivos e " ^& FoldersSkipped ^& " Pastas já estavam maiúsculas."
  21. Echo. End Sub
  22. Echo. Sub ProcessFolder (ByVal Folder^)
  23. Echo. Dim Files: Set Files = Folder.Files
  24. Echo. Dim File
  25. Echo. For Each File In Files
  26. Echo. If File.Name ^<^> LCase(File.Name^) Then
  27. Echo. File.Move UCase(File.Path^)
  28. Echo. FilesRenamed = FilesRenamed + 1
  29. Echo. Else
  30. Echo. FilesSkipped = FilesSkipped + 1
  31. Echo. End If
  32. Echo. Next
  33. Echo. Dim SubFolders: Set SubFolders = Folder.SubFolders
  34. Echo. Dim SubFolder
  35. Echo. For Each SubFolder In SubFolders
  36. Echo. If SubFolder.Name ^<^> LCase(SubFolder.Name^) Then
  37. Echo. SubFolder.Move UCase(SubFolder.Path^)
  38. Echo. FoldersRenamed = FoldersRenamed + 1
  39. Echo. Else
  40. Echo. FoldersSkipped = FoldersSkipped + 1
  41. Echo. End If
  42. Echo. ProcessFolder SubFolder
  43. Echo. Next
  44. Echo. End Sub
  45. Echo. Function PromptYesNo (ByVal PromptText^)
  46. Echo. Do
  47. Echo. StdOut.Write PromptText ^& " (S/N) - "
  48. Echo. Dim s: s = StdIn.ReadLine(^)
  49. Echo. Select Case LCase(Trim(s^)^)
  50. Echo. Case "N","n","nao"  PromptYesNo = False: Exit Function
  51. Echo. Case "S","s","Sim" PromptYesNo = True:  Exit Function
  52. Echo. End Select
  53. Echo. StdOut.WriteLine "Invalid input."
  54. Echo. Loop
  55. Echo. End Function
  56. )>File.vbs
  57. CSCRIPT //NOLOGO File.vbs
  58. PAUSE
  59.  
Advertisement
Add Comment
Please, Sign In to add comment