- @echo off
-
- REM 获取bat上级路径
-
-
- set "bd=%cd%"
- cd..
- set "bbd=%cd%"
- cd %bd%
- set Newdisk=%bbd%
-
- set strIceBoxFilePath=d:\sec\icebox\icebox.txt
- REM 读取旧盘符
- set Olddisk=
- for /f "tokens=1*" %%i in ('findstr "IceBox\\" "%strIceBoxFilePath%"') do (
- set Olddisk=%%j
- )
- if not defined Olddisk exit /b
- set "prefix=%Olddisk%\."
- @REM echo prefix_before=%prefix%
- :loop3
- for %%A in ("%prefix%") do (
- set "prefix=%%~dpA."
- if /i not "%%~nxA"=="IceBox" if not "%%~pA"=="\" (
- goto loop3
- )
- )
- set "prefix=%prefix:~,-1%"
- @REM echo prefix_after=%prefix%
- REM 读取IceBox_*.dat所有内容
- for /f "eol=! tokens=*" %%l in (%strIceBoxFilePath%) do (
-
-
- REM 设置变量str为每行内容
-
- setlocal EnableDelayedExpansion
- set str=%%l
- REM 如果该行有旧盘符a,则将其改为新盘符A
- set "str=!str:%prefix%=%Newdisk%\!"
-
-
- REM 把修改后的全部行存入$
- echo !str!>>$
- endlocal
-
- )
-
-
- REM 替换原文件
-
-
- move $ %strIceBoxFilePath%
-
-
- echo 设置完成!
复制代码
|