::设置备份文件夹路径 set bakpth=D:\UDISKBAK ::变量type值为空则默认备份U盘中所有文件,如只备份.RAR类型文件,则 set type=.RAR ,以此类推 set type= ::取得U盘盘符并执行备份操作 for %%a in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do ( fsutil fsinfo drivetype %%a:|findstr "可移动">Nul(set udisk=%%acall :ucopy) ) exit
:ucopy if not exist "%bakpth%\%udisk%" md "%bakpth%\%udisk%" ::复制U盘文件,默认不复制空文件夹,如果需要复制空文件夹,则将下行命令开关/s改为/e xcopy /s/h/y %udisk%:\*%type% "%bakpth%\%udisk%" >nul 2>nul goto :eof