Recursively purging, renumbering and cleaning files in a folder.
This batch file should be executed in the folder you wish recursively purge, clean and rename in or .... better yet ... install the ".inf" file and run this by simply "right clicking" on a folder from the Windows Explorer. This will also rename all the Pro/ENGINEER files to a ".1" extension so files can more easily be shared .
ProReNumber.bat
@echo off
title ProReNumber
if !%1==! goto :nopath
if not exist %1*.* goto :badpath
path=%path%;<path to your Pro/E loadpoint/bin folder>
:start
time /t
call :subrenumber "%1"
FOR /D /R %%d IN (*.*) do call :subrenumber "%%d"
time /t
goto:eof
:subrenumber
cd /d "%1"
echo Changing Attributes.. %1
IF EXIST *.* attrib -R -H *.*
time /t
echo Purging.............. %1
call purge.bat
time /t
echo Renumbering.......... %1
for /F "tokens=1,2,3 delims=. " %%I in ('dir /b *.asm.* *.prt.* *.drw.* *.frm.* *.gph.* *.win.* *.tbl.* *.sym.*') do (
if %%K GTR 1 Call :ReNameFile %%I %%J %%K
)
time /t
goto :Cleaning
:ReNameFile
if exist %1.%2.%3 ren %1.%2.%3 %1.%2.1
goto :complete
:Cleaning
echo Cleaning............. %1
IF EXIST .* del /q .*
IF EXIST *.als del /q *.als
IF EXIST *.log.* del /q *.log.*
IF EXIST *.inf.* del /q *.inf.*
IF EXIST *.crc.* del /q *.crc.*
IF EXIST *.ref.* del /q *.ref.*
IF EXIST *.ptd.* del /q *.ptd.*
IF EXIST *.tst.* del /q *.tst.*
IF EXIST *.memb.* del /q *.memb.*
IF EXIST *.ers.* del /q *.ers.*
IF EXIST *.info.* del /q *.info.*
IF EXIST *.lst.* del /q *.lst.*
IF EXIST *.ncl.* del /q *.ncl.*
IF EXIST *.shd.* del /q *.shd.*
IF EXIST *.tph.* del /q *.tph.*
IF EXIST *.ger.* del /q *.ger.*
IF EXIST *.m_p.* del /q *.m_p.*
IF EXIST *.plt.* del /q *.plt.*
IF EXIST *.err.* del /q *.err.*
IF EXIST *.xrp del /q *.xrp
IF EXIST trail.txt* del /q trail.txt*
IF EXIST pdm_trl* del /q pdm_trl*
IF EXIST std.out del /q std.out
IF EXIST rename_this_*.* del /q rename_this_*.*
IF EXIST prt????.prt* del /q prt????.prt*
IF EXIST asm????.asm* del /q asm????.asm*
IF EXIST dgm????.dgm* del /q dgm????.dgm*
IF EXIST drw????.drw* del /q drw????.drw*
IF EXIST s2d????.sec* del /q s2d????.sec*
IF EXIST lay????.lay* del /q lay????.lay*
IF EXIST ptcs.txt del /q ptcs.txt
IF EXIST ptcf.cmd del /q ptcf.cmd
goto :complete
:nopath
echo.
echo ERROR - No path provided.
echo.
pause
goto :complete
:badpath
echo.
echo ERROR - "%1" is not a valid path.
echo.
pause
goto :complete
:complete
echo.
This is the ".inf" file that can be installed in Windows (save it with the ".inf" extension and then "Right Click" on it and select "Install").
ProReNumber.inf
[version]
signature="$Windows NT$"
[DefaultInstall]
CopyFiles=Files.Inf, Files.App
AddReg=Reg.Add
[DefaultUnInstall]
DelFiles=Files.Inf, Files.App
DelReg=Reg.Del
[DestinationDirs]
Files.Inf=17
Files.App=11
[Files.Inf]
ProReNumber.INF
[Files.App]
ProReNumber.bat
[Reg.Add]
HKLM,%Key_Menu%,DisplayName,,"%AppName%"
HKLM,%Key_Menu%,UninstallString,,"rundll32.exe setupapi.dll,InstallHinfSection DefaultUnInstall 132 %17%\ProReNumber.inf"
HKCR,Directory\Shell\ProReNumber,,,"%AppMenu%"
HKCR,Directory\Shell\ProReNumber\command,,,"%11%\cmd.exe /c %11%\ProReNumber.bat "%1"
[Reg.Del]
HKLM,%Key_Menu%
HKCR,Directory\Shell\ProReNumber
[Strings]
AppName="Pro/E Recursive Renumber Command (Remove)"
AppMenu="ProReNumber"
Key_Menu="Software\Microsoft\Windows\CurrentVersion\Uninstall\ProReNumber"