Skip to content

Instantly share code, notes, and snippets.

@Lycheejam
Created October 30, 2017 11:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lycheejam/8473c424a27cc885971e6d5ad3772fbc to your computer and use it in GitHub Desktop.
Save Lycheejam/8473c424a27cc885971e6d5ad3772fbc to your computer and use it in GitHub Desktop.
Public Sub txtSearch(Path As String, copySaki As String)
Dim buf As String
Dim f As Object
Dim saki As String
Dim moto As String
buf = Dir(Path & "\*.txt")
'dirで指定の拡張子があればbufに格納される
'bufにファイル名が入っていればコピー実行
Do While buf <> ""
moto = Path & "\" & buf
saki = copySaki & "\" & buf
FileCopy moto, saki
buf = Dir()
Loop
'フォルダがある限り自分を呼び出して潜り続けて最後まで行くと一個戻ってまた潜る
With CreateObject("Scripting.FileSystemObject")
For Each f In .getfolder(Path).subfolders
Call txtSearch(f.Path, copySaki)
Next f
End With
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment