Proe/Creo 零件库mnu文件制作批处理

proe零件库自定义时需要菜单文件mnu,百度了下网上还没有人制作,偶然间Google时在PTC论坛上看到一德国人分享了自己制作的bat文件用于对文件夹(及子文件夹)产生mnu文件,我在将他的文件翻译下并分享出来:

复制下面黄色高亮部分至记事本程序,并保存文bat文件(我的文件名是make_mnu.bat):

@ echo off

:: syntax:   make_mnu.bat [path]\folder

if not defined temp goto echo Variable "TEMP" ist nicht definiert! & goto :error

if exist %temp%\tmpfile.$$$ del %temp%\tmpfile.$$$

set root_folder=%~1
rem How do I get rid of the possible quotes?
if not exist "%root_folder%" echo. The folder You specified was not found! & goto :error

cls
echo. Danger!!
echo. All *.mnu - Files are deleted.
echo. Please choose: [Y]yes or [N]no ?
set/p choice=
if /i "%choice%"=="n" echo cancellation! & goto :error


echo> %temp%\tmpfile.$$$ %root_folder%
dir /s /b /ad /on %root_folder% >> %temp%\tmpfile.$$$

for /f "tokens=*" %%a in (%temp%\tmpfile.$$$) do call :begin_loop_folders "%%a"
goto :end_loop_folders
:begin_loop_folders
echo. editing %~1
if exist "%~1\*.mnu" del "%~1\*.mnu"
set mnu_text=%~n1
echo %mnu_text:_=#% > "%temp%\tmp_mnu.$$$"
echo #>> "%temp%\tmp_mnu.$$$"
echo #>> "%temp%\tmp_mnu.$$$"

for /f "tokens=*" %%b in ('dir /b /on %~1') do call :begin_loop_files "%~1" "%%b"
goto :end_loop_files
:begin_loop_files
set mnu_text=%~n2
dir %~1\%~2 | find /i "

" 1> nul 2> nul
if "%errorlevel%"=="0" (
set slash=/
set extension=
) else (
set slash=
set extension=%~x2
)
echo %slash%%mnu_text: =#%%extension%>> "%temp%\tmp_mnu.$$$"
echo #>> "%temp%\tmp_mnu.$$$"
echo #>> "%temp%\tmp_mnu.$$$"
goto :eof
:end_loop_files
move "%temp%\tmp_mnu.$$$" "%~1\%~n1.mnu"
echo. finished!
echo.
goto :eof
:end_loop_folders

del "%temp%\tmpfile.$$$"

echo finished!

:error
pause

:end
:eof

测试发现仅对win7以下系统适用。

 

转载于:https://www.cnblogs.com/turbochen/p/10421677.html

你可能感兴趣的:(Proe/Creo 零件库mnu文件制作批处理)