应该是查找文件夹的姿势不对,不是系统差异,是文件夹位置差异
| @echo off | | cd /d "%~dp0" | | set "target=PETOOLS" | | set "regfile=1.reg" | | set "found=" | | 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 ( | | if exist "%%a:\" ( | | for /f "delims=" %%d in ('dir /b /s /ad "%%a:\%target%?"') do ( | | if /i "%%~nxd" equ "%target%" ( | | if /i "%%d" neq "%%a:\%target%" ( | | set found=%%d | | call set "found=%%found:\=\\%%" | | goto :replace | | ) | | ) | | ) | | ) | | ) | | :replace | | if defined found ( | | (for /f "delims=" %%a in ('find /n /v "" ^< "%regfile%"') do ( | | set str=%%a | | setlocal enabledelayedexpansion | | set "str=!str:C:\\PETOOLS=%found%!" | | echo=!str:*]=! | | endlocal | | )) > # | | move # "%regfile%" | | echo SUCCESS | | ) else ( | | echo FAILED | | ) | | pauseCOPY |
|