Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Example of bat file to run Nastran for every *.dat file in the current folder 2

Status
Not open for further replies.

gantovnik

Aerospace
Nov 9, 2011
15
This is example of Windows bat file to run Nastran for every *.dat file in the current folder.
It also calculates the total Nastran execution time. Of course, you should change path to nastran.exe. The nice thing here is that script uses variable set MyPath=%cd%, so you don't need to enter path for *.dat files Enjoy! :)

Code:
REM @echo off
@setlocal 
set start=%time%
set MyPath=%cd%
del %MyPath%\*.f04
del %MyPath%\*.f06
del %MyPath%\*.log
del %MyPath%\*.xdb
del %MyPath%\*.rcf
for %%x in (*.dat) do K:\prod\wnt\Nastran\2016\bin\nastran.exe old=no scr=yes news=no mem=max parallel=2 %MyPath%\%%x
set end=%time%
set options="tokens=1-4 delims=:."
for /f %options% %%a in ("%start%") do set start_h=%%a&set /a start_m=100%%b %% 100&set /a start_s=100%%c %% 100&set /a start_ms=100%%d %% 100
for /f %options% %%a in ("%end%") do set end_h=%%a&set /a end_m=100%%b %% 100&set /a end_s=100%%c %% 100&set /a end_ms=100%%d %% 100
set /a hours=%end_h%-%start_h%
set /a mins=%end_m%-%start_m%
set /a secs=%end_s%-%start_s%
set /a ms=%end_ms%-%start_ms%
if %hours% lss 0 set /a hours = 24%hours%
if %mins% lss 0 set /a hours = %hours% - 1 & set /a mins = 60%mins%
if %secs% lss 0 set /a mins = %mins% - 1 & set /a secs = 60%secs%
if %ms% lss 0 set /a secs = %secs% - 1 & set /a ms = 100%ms%
if 1%ms% lss 100 set ms=0%ms%
:: mission accomplished
set /a totalsecs = %hours%*3600 + %mins%*60 + %secs% 
echo command took %hours%:%mins%:%secs%.%ms% (%totalsecs%.%ms%s total)
set /a totalmins = %hours%*60 + %mins%*1
echo command took %totalmins% minutes > time.txt
echo command took %totalsecs% seconds >> time.txt
timeout /t 5



Vladimir Gantovnik, PhD
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor