2011-09-03 4 views
0

일괄 스크립팅을 처음 사용합니다. 프로그래밍 방식으로 폴더를 찾은 다음 현재 디렉터리의 내용을 지정된 디렉터리에 복사하려고합니다.찾아보기 폴더에 대한 일괄 처리 명령

폴더를 찾을 수있는 VBScript 스크립트 (아래)가 있습니다. 배치 파일을 어떻게 링크 할 수 있습니까? 즉, 스크립트를 실행하고 폴더를 선택한 후에는 파일을 선택한 폴더로 이동해야합니다. 가능한가?

다음 폴더를 찾아 내 VBScript 코드는 다음과 같습니다

Option Explicit 

WScript.Echo BrowseFolder("C:\Program Files", True) 
WScript.Echo BrowseFolder("My Computer", False) 
WScript.Echo BrowseFolder("", False) 


Function BrowseFolder(myStartLocation, blnSimpleDialog) 
' This function generates a Browse Folder dialog 
' and returns the selected folder as a string. 
' 
' Arguments: 
' blnSimpleDialog [boolean] if False, an additional text field will be 
'        displayed where the folder can be selected 
'        by typing the fully qualified path 
' 
' Returns:   [string] the fully qualified path to the selected folder 
' 
' Based on the Hey Scripting Guys article 
' "How Can I Show Users a Dialog Box That Only Lets Them Select Folders?" 
' http://www.microsoft.com/technet/scriptcenter/resources/qanda/jun05/hey0617.mspx 
' 
' Function written by Rob van der Woude 
' http://www.robvanderwoude.com 
    Const MY_COMPUTER = &H11& 
    Const WINDOW_HANDLE = 0 ' Must ALWAYS be 0 

    Dim numOptions, objFolder, objFolderItem 
    Dim objPath, objShell, strPath, strPrompt 

    ' Set the options for the dialog window 
    strPrompt = "Select a folder:" 
    If blnSimpleDialog = True Then 
    numOptions = 0  ' Simple dialog 
    Else 
     numOptions = &H10& ' Additional text field to type folder path 
    End If 

    ' Create a Windows Shell object 
    Set objShell = CreateObject("Shell.Application") 

    ' If specified, convert "My Computer" to a valid 
    ' path for the Windows Shell's BrowseFolder method 
    If UCase(myStartLocation) = "MY COMPUTER" Then 
     Set objFolder = objShell.Namespace(MY_COMPUTER) 
     Set objFolderItem = objFolder.Self 
     strPath = objFolderItem.Path 
    Else 
     strPath = myStartLocation 
    End If 

    Set objFolder = objShell.BrowseForFolder(WINDOW_HANDLE, strPrompt, _ 
              numOptions, strPath) 

    ' Quit if no folder was selected 
    If objFolder Is Nothing Then 
     BrowseFolder = "" 
     Exit Function 
    End If 

    ' Retrieve the path of the selected folder 
    Set objFolderItem = objFolder.Self 
    objPath = objFolderItem.Path 

    ' Return the path of the selected folder 
    BrowseFolder = objPath 
End Function 
+0

http://stackoverflow.com/questions/3470880/move-folder-from-one- 디렉토리 대 다른 배치 스크립트 –

답변

0

당신은 당신이로 VBScript를 함께 일괄 적으로 동일한 기능을 사용 하시겠습니까? 그렇다면 나는 Visual Studio와 C# (볼 가치가있는)을 사용하여 OpenFileDialog를 배치와 함께 사용할 수 있다고 생각하지 않습니다. 당신이 일괄 처리를하고 싶은 경우에 당신은이를 사용할 수 있습니다

set /p path=Enter folder path: 
xcopy /e %cd% %path% 
0

당신은 정말 배치를 사용하려는 경우에는 환경 변수에 값을 전달 또는 파이프에 값을 io.out에 기록 할 수 있지만, 이들 중 어느 것도 바람직하지 않습니다. 또한 값을 임시 텍스트 파일에 쓰고 일괄 처리에서 해당 값을 imput으로 사용할 수도 있습니다. 가장 쉽고 간단한 해결책은 스크립트 자체에서 복사하는 것입니다. 샘플을 많이 사용하고 오류 상황에도 대응할 가능성이 더 많습니다. 하나를 찾을 수 없다면 알려주세요. 게시하기 전에 일부 데이터를 삭제해야합니다.