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 "<DIR>" 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以下系統適用。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM