Search code examples
batch-filecopytransferxcopy

How to get number of files transferred as a variable?


xcopy /Y /E /H "C:\test1" "C:\test2"  

Returns a number of files copied, how do I get that number as a variable?

Thanks in advance!


Solution

  • for /f "tokens=1" %%a in ('xcopy /Y /E /H "C:\test1" "C:\test2" ') do (
      set copied_files=%%a
    )
    echo %copied_files%
    

    not tested.