Skip to content

Instantly share code, notes, and snippets.

@davidtolsma
Created November 25, 2010 15:38
Show Gist options
  • Save davidtolsma/715540 to your computer and use it in GitHub Desktop.
Save davidtolsma/715540 to your computer and use it in GitHub Desktop.
Unigraphics NX native refile utility to a newer version of NX
@echo OFF
TITLE REFILE
cls
:: Where I'm running this script from.
set currentDirectory=%~d0
set currentPath=%~p0
set thisScriptPath=%~dp0
:: USER SETTINGS
set logDirectory=logs
:: System Variables
set outputFilePlusPath=%thisScriptPath%\%logDirectory%\%outputFile%
set programName=refile_part.exe
set backgroundColor=4
set foregroundColor=7
set inputDirectory=%1
set outputFile=%2
if "%inputDirectory%"=="" GOTO :ENVIRONMENTNOTSET
if "%outputFile%"=="" GOTO :ENVIRONMENTNOTSET
:: OPTIONS
set compressParts=TRUE
set createTrueShapeData=FALSE
set partCleanup=FALSE
set otherArguments=-ll -r
IF "%compressParts%"=="TRUE" (set compressParts=-co) ELSE (set compressParts= )
IF "%createTrueShapeData%"=="TRUE" (set createTrueShapeData=-ts) ELSE ( set createTrueShapeData= )
IF "%partCleanup%"=="TRUE" (set partCleanup=-cleanup) ELSE ( set partCleanup= )
set arguments=%compressParts% %createTrueShapeData% %partCleanup% %otherArguments%
if "%UGII_BASE_DIR%"=="" GOTO :ENVIRONMENTNOTSET
if "%UGII_ROOT_DIR%"=="" set UGII_ROOT_DIR=%UGII_BASE_DIR%UGII
::Put the Time and Day into the top of the file when it was started
:: Create a new file if one already exists
echo Started: %DATE% %TIME% > %outputFilePlusPath%
echo. >> %outputFilePlusPath%
echo. >> %outputFilePlusPath%
:: Set the background and foreground color to show that it is working
color %backgroundColor%%foregroundColor%
echo Working...
:: Look for .prt files recursively in all folders
for /R %inputDirectory% %%f in (*.prt) DO CALL :RUN_REFILE %%f
:: Sets the background and foreground color back to standard
color 07
::Put the Time and Day into the bottom of the file when it was Completed
echo. >> %outputFilePlusPath%
echo. >> %outputFilePlusPath%
echo Finished: %DATE% %TIME% >> %outputFilePlusPath%
:: Open the log file
start notepad %outputFilePlusPath%
GOTO :QUIT
:RUN_REFILE
set fileName=%*
echo.
echo %programName% %fileName% %arguments% >> %outputFilePlusPath%
echo Processing: %fileName%
set processCommand=%programName% %fileName% %arguments% >> %outputFilePlusPath%
%processCommand%
GOTO :EOF
:ENVIRONMENTNOTSET
echo.
echo USAGE: %~0 inputDirectory logfile
echo.
echo EXAMPLE: %~0 C:\test_folder refileInformation.txt
echo.
%programName%
GOTO QUIT
:QUIT
:: Set the Toolbar back to CMD
title %comspec%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment