Reference a Volume/Drive by Label

前端 未结 3 1442
天涯浪人
天涯浪人 2020-12-18 04:54

I\'m trying to write a batch file to xcopy a folder to a removable USB drive. The problem that I face, however, is that drive letters are subject to change, so I would like

3条回答
  •  爱一瞬间的悲伤
    2020-12-18 05:09

    This works in Windows XP:

    for /f %%D in ('wmic LogicalDisk get Caption^, VolumeName ^| find "DRIVE_LABEL"') do set DRIVE=%%D
    

    (Use %D instead of %%D if run directly from command line.)

提交回复
热议问题