如何用批处理遍历文件夹

http://blog.sina.com.cn/s/blog_6f3da96501011so3.html
Sub Sample1(strPath As String, strName As String)
'strPath: path which to be searched
'strName: filename which will be created

  Set WSH = CreateObject("WScript.Shell")
  iFileNum = FreeFile
  sTempFileName = "G:\备份\myfile.bat"
  Open sTempFileName For Output As #iFileNum
  Print #iFileNum, "@echo off"
  Print #iFileNum, "for /f ""delims="" %%i in ('dir " & strPath & " /a-d /b /s /od') do echo %%~ti,%%~dpnxi >> G:\备份\" & strName & ".csv"
  Close #iFileNum

'Invoke Batch Program".
  Set wExec = WSH.Exec("%ComSpec% /c" & sTempFileName)
    Do While wExec.Status = 0
        DoEvents
    Loop
    Set wExec = Nothing
    Set WSH = Nothing

End Sub

你可能感兴趣的:(如何用批处理遍历文件夹)