与根驱动器无关的副本
我想在Windows中编写一个bat文件,它将一些文件复制到当前目录中:
copy C:\Folder1\Folder2\file1.ext .\
copy C:\Folder3\Folder4\Folder5\file2.ext2 .\
...
我希望有以下行为:如果从根驱动器X的路径执行bat,我希望它复制相同的文件(使用相同的路径)来自 X
copy X:\Folder1\Folder2\file1.ext .\
copy X:\Folder3\Folder4\Folder5\file2.ext2 .\
...
我怎样才能实现这一目标?即如何从当前目录获取根驱动器的名称? 希望我的问题很清楚。
I want to write a bat file in windows which would do copy some files into the current directory:
copy C:\Folder1\Folder2\file1.ext .\
copy C:\Folder3\Folder4\Folder5\file2.ext2 .\
...
I would like to have the following behavior: If the bat is executed from a path with root drive X, I want it to copy the same files (with the same paths) from X
copy X:\Folder1\Folder2\file1.ext .\
copy X:\Folder3\Folder4\Folder5\file2.ext2 .\
...
How can I achieve this? i.e. how can I get the root drive's name from the current directory?
Hope my question was clear.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你不能简单地省略驱动器号吗? AFAIK 它是可选的,
\Folder\Foo
应该是当前驱动器上的有效绝对路径。Can’t you simply leave out the drive letter? AFAIK it’s optional,
\Folder\Foo
should be a valid absolute path on the current drive.批处理语言的规则是,当你不知道如何做某件事时,它可能会涉及到
for
。The rule of batch language is that when you don't know how to do something, it probably involves
for
.