×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

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

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

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

(OP)
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
http://gantovnik.com/aerospace/index.php

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources