使用批处理文件的文件复制到USB闪存驱动器根
问题描述:
我想创建一个批处理文件,将文件从任何目录复制到.bat文件位于像USB闪存驱动器的根文件夹。
I want to create a batch file to copy a file from any Dir into root folder that the .bat file located on that like a USB flash drive .
我的不完整的命令:
xcopy /s "%userprofile%\Desktop\test.txt" "?"
我能和替代哪些? ???
谢谢你们
What can I replace with "?" ??? Thanks guys
答
这将不正是你想要的任何及所有连接的USB驱动器。
This will do exactly as you want to any and all connected USB drives.
@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 (
xcopy /s "%userprofile%\Desktop\test.txt" %%i\
)
)