HerveyHu 当前离线
列兵
REM 获取bat上级路径 set "bd=%cd%" cd.. set "bbd=%cd%" cd %bd% set Newdisk=%bbd% REM 读取旧盘符 for /f "tokens=1 delims=\" %%i in ('findstr "IceBox\\" "%strIceBoxFilePath%"') do ( for /f "tokens=2 delims= " %%j in ("%%i") do ( set OldDisk=%%j ) ) REM 读取IceBox_*.dat所有内容 for /f "eol=! tokens=*" %%l in (%strIceBoxFilePath%) do ( REM 设置变量str为每行内容 set str=%%l REM 如果该行有旧盘符a,则将其改为新盘符A set "str=!str:%Olddisk%\=%Newdisk%\!" REM 把修改后的全部行存入$ echo !str!>>$ ) REM 替换原文件 move $ %strIceBoxFilePath% echo 设置完成!复制代码
TOP
flashercs 当前在线
少校
if %errorlevel% equ 1 powershell -NoProfile -Command "(Get-Content -LiteralPath \"%strConfigFilePath%\" -ReadCount 0 -Encoding utf8) -replace \"(%Pathtype%\s+).*?(?=\\IceBox\\IceBox_%c%.dat)\", \"`${1}%Newdisk%\" | Set-Content -Encoding utf8 -LiteralPath \"%strConfigFilePath%\""||del /f /s /q /a "%bct%$"复制代码
@ echo off & setlocal enabledelayedexpansion REM 声明采用UTF-8编码 chcp 65001 cls REM 定义config.pro文件路径 :loop1 set /p input=请复制粘贴config.pro所在文件夹路径!: set strConfigFilePath=%input%\config.pro if not exist %strConfigFilePath% echo 没有找到 config.pro 文件,请重新复制路径!& goto loop1 REM 获取bat上级路径 set "bd=%cd%" cd.. set "bbd=%cd%" cd %bd% set Newdisk=%bbd% REM 获取bat当前路径 set bct=%~dp0 REM 确认Proe/Creo版本 :loop2 echo. set Num= echo. 1 wildFire5.0 echo. 2 Creo 2.0 echo. 3 Creo 3.0 echo. 4 Creo 4.0 + set /p Num=请输入对应软件前面的序号,按Enter确认: echo. set "Num=%Num:~,1%" if "%Num:"=""%" equ "1" goto ver if "%Num:"=""%" equ "2" goto ver if "%Num:"=""%" equ "3" goto ver if "%Num:"=""%" equ "4" goto ver echo 输入有误,请重新输入!!! goto loop2 :ver REM 设置参数类型 if %Num% GTR 1 (set Pathtype=creotkdat) else (set Pathtype=proetkdat) REM 提取版本号 set b=wf c2 c3 c4 for /f "tokens=%Num% delims= " %%a in ("%b%") do (set c=%%a) set strIceBoxFilePath=%bct%IceBox_%c%.dat findstr /ric:"%Pathtype% *.*\\IceBox\\IceBox_%c%.dat" %strConfigFilePath% if %errorlevel% equ 1 ( REM 未找到 >>%strConfigFilePath% echo %Pathtype% %Newdisk%\IceBox\IceBox_%c%.dat goto next ) REM 找到 set reNewdisk=%Newdisk:\=\\% set reNewdisk=%reNewdisk:\.=\.% findstr /ric:"%Pathtype% *%reNewdisk%\\IceBox\\IceBox_%c%.dat" %strConfigFilePath% REM 不匹配%Newdisk% if %errorlevel% equ 1 powershell -NoProfile -Command "(Get-Content -LiteralPath \"%strConfigFilePath%\" -ReadCount 0) -replace \"(%Pathtype%\s+).*?(?=\\IceBox\\IceBox_%c%.dat)\", \"`${1}%Newdisk%\" | Set-Content -LiteralPath \"%strConfigFilePath%\""||del /f /s /q /a "%bct%$" :next REM IceBox_*.dat 更改路径 REM 读取旧路径 set Olddisk= for /f "tokens=1*" %%i in ('findstr "IceBox\\" "%strIceBoxFilePath%"') do ( set Olddisk=%%j ) 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 "tokens=*" %%k in (%strIceBoxFilePath%) do ( REM 设置变量str为每行内容 set str=%%k REM 如果该行有旧盘符路径a,则将其改为新盘符路径A set "str=!str:%prefix%=%Newdisk%\!" REM 把修改后的全部行存入$ echo !str!>>$ ) REM 替换原文件 move $ %strIceBoxFilePath% echo 设置完成! choice /t 1 /d y /n >nul exit复制代码
@echo off chcp 65001 REM 获取bat上级路径复制代码
@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% set strConfigFilePath=d:\sec\icebox\icebox.txt findstr /ric:"creotkdat *.*\\IceBox\\IceBox_c4.dat" %strConfigFilePath% if %errorlevel% equ 1 ( REM 未找到 >>%strConfigFilePath% echo creotkdat %Newdisk%\IceBox\IceBox_c4.dat goto end ) set reNewdisk=%Newdisk:\=\\% set reNewdisk=%reNewdisk:\.=\.% REM 找到 findstr /ric:"creotkdat *%reNewdisk%\\IceBox\\IceBox_c4.dat" %strConfigFilePath% REM 不匹配%Newdisk% if %errorlevel% equ 1 powershell -NoProfile -Command "(Get-Content -LiteralPath \"%strConfigFilePath%\" -ReadCount 0) -replace \"(creotkdat\s+).*?(?=\\IceBox\\IceBox_c4.dat)\", \"`${1}%Newdisk%\" | Set-Content -LiteralPath \"%strConfigFilePath%\"" :end echo 设置完成!复制代码
findstr /ric:"creotkdat *.*\\IceBox\\IceBox_c4.dat" %strConfigFilePath% if %errorlevel% equ 1 >>%strConfigFilePath% echo creotkdat %Newdisk%\IceBox\IceBox_c4.dat复制代码