只能修改两个临近的盘,比如当前盘为D盘,临近的后一个盘是E盘。把D盘改为X盘,E盘改为Y盘。
- @echo off
- set newvol1=X
- set newvol2=Y
-
- set /p currvol=请输入想要修改的盘符(输入格式:D):
- for /f "delims=" %%i in ('mountvol %currvol%: /l') do set volname=%%i
- mountvol %currvol%: /d
- mountvol %newvol1%: %volname%
-
- set str=C D E F G H I J K L M N O P Q R S T U V W X Y Z
- for %%j in (%str%) do (
- set /a n+=1
- if %%j==%currvol% goto next
- )
- :next
- setlocal enabledelayedexpansion
- set string=%str: =%
- set nextvol=!string:~%n%,1!
- for /f "delims=" %%a in ('mountvol %nextvol%: /l') do set nextvolname=%%a
- mountvol %nextvol%: /d
- mountvol %newvol2%: %nextvolname%
复制代码
[ 本帖最后由 keen 于 2009-11-2 20:58 编辑 ] |