引用由标签卷/驱动器 [英] Reference a Volume/Drive by Label

查看:156
本文介绍了引用由标签卷/驱动器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个批处理文件到一个文件夹XCOPY到可移动的USB驱动器。我面临的问题,但是,是驱动器号如有变更,所以我希望能够通过引用卷标而不是驱动器盘符来做到这一点。

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 to be able to do this by referencing the volume label instead of the drive letter.

任何想法?谷歌,荷兰国际集团一小时已被证明无果而终。 (

Any ideas? An hour of Google-ing has proved fruitless. :(

推荐答案

这个命令应该发现与正确的标签的驱动器和存储驱动器号(与结肠癌)的变量USB

This command should discover the drive with the correct label and store the drive letter (with colon) in variable "usb"

for /f %%D in ('wmic volume get DriveLetter^, Label ^| find "yourLabel"') do set usb=%%D

您可以,如果你喜欢直接嵌入您的xcopy命令(S)的DO子句。 %% D包含驱动器号。

You could embed your xcopy command(s) directly in the DO clause if you like. %%D contains the drive letter.

这篇关于引用由标签卷/驱动器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆