Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. Dim FSO As Object
  2. Dim FromPath As String
  3. Dim ToPath As String
  4. Dim objFSO As Object
  5. Dim objFolder As Object
  6. Dim objSubFolder As Object
  7. Dim fil As File
  8.  
  9. With Application.FileDialog(msoFileDialogFolderPicker) 'Choosing FromPath
  10. .Show
  11. FromPath = .SelectedItems(1) & ""
  12. End With
  13.  
  14. With Application.FileDialog(msoFileDialogFolderPicker) 'Choosing ToPath
  15. .Show
  16. ToPath = .SelectedItems(1) & ""
  17. End With
  18.  
  19.  
  20. Set objFSO = CreateObject("Scripting.FileSystemObject")
  21. Set objFolder = objFSO.GetFolder(FromPath)
  22. For Each objSubFolder In objFolder.SubFolders
  23. **Set fils = fsoC.GetFolder(objSubFolder & "").Files**
  24.  
  25. For Each fil In fils
  26. If LCase(Right(fil.Name, 3)) = "zip" Then
  27. MsgBox "this is a zip file "
  28. Else
  29.  
  30. Sub test()
  31. Dim fils As Object
  32. Dim fil As Object
  33. Dim FromPath As String
  34. Dim ToPath As String
  35. Dim objFSO As Object
  36. Dim objFolder As Object
  37. Dim objSubFolder As Object
  38.  
  39. With Application.FileDialog(msoFileDialogFolderPicker) 'Choosing FromPath
  40. .Show
  41. FromPath = .SelectedItems(1) & ""
  42. End With
  43.  
  44. With Application.FileDialog(msoFileDialogFolderPicker) 'Choosing ToPath
  45. .Show
  46. ToPath = .SelectedItems(1) & ""
  47. End With
  48.  
  49.  
  50. Set objFSO = CreateObject("Scripting.FileSystemObject")
  51. Set objFolder = objFSO.GetFolder(FromPath)
  52. For Each objSubFolder In objFolder.SubFolders
  53. Set fils = objFSO.GetFolder(objSubFolder & "").Files
  54.  
  55. For Each fil In fils
  56. If LCase(Right(fil.Name, 3)) = "zip" Then
  57. MsgBox "this is a zip file "
  58. Else
  59. MsgBox "NOPE"
  60. End If
  61. Next
  62. Next
  63. End Sub
  64.  
  65. A
  66. -- A.1
  67. ---- test.txt
  68. ---- test.zip
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement