Detect USB and copy *.* to USB drive using batch script

前端 未结 4 719
野性不改
野性不改 2020-12-15 14:13

I am trying to write a batch script to detect a USB drive and, if it is plugged in, for example copy c:\\test\\big.txt to the USB drive, and looping to detect anoth

4条回答
  •  甜味超标
    2020-12-15 14:41

    I know this is old but....

    @echo off
    
    for /F "usebackq tokens=1,2,3,4 " %%i in (`wmic logicaldisk get caption^,description^,drivetype 2^>NUL`) do (
    
    if %%l equ 2 (
    copy c:\test\big.txt %%i
            )
            )
    

    This is assuming of course both drives are inserted.

提交回复
热议问题