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 |
如何用批处理遍历文件夹
最新推荐文章于 2024-05-13 17:20:48 发布