batch file Copy files with certain extensions from multiple directories into one directory

后端 未结 5 1394
别那么骄傲
别那么骄傲 2020-11-30 19:33

I\'m a newbie, so bear with me...

I am trying to copy all .doc files that I have scattered throughout several subdirectories of one main directory into

5条回答
  •  一整个雨季
    2020-11-30 20:24

    you can also use vbscript

    Set objFS = CreateObject("Scripting.FileSystemObject")
    strFolder = "c:\test"
    strDestination = "c:\tmp\"
    Set objFolder = objFS.GetFolder(strFolder)
    
    Go(objFolder)
    
    Sub Go(objDIR)
      If objDIR <> "\System Volume Information" Then
        For Each eFolder in objDIR.SubFolders       
            Go eFolder
        Next
        For Each strFile In objDIR.Files
            strFileName = strFile.Name
            strExtension = objFS.GetExtensionName(strFile)
            If strExtension = "doc" Then
                objFS.CopyFile strFile , strDestination & strFileName
            End If 
        Next    
      End If  
    End Sub 
    

    save as mycopy.vbs and on command line

    c:\test> cscript /nologo mycopy.vbs
    

提交回复
热议问题