python Cleanup script to delete unnecessary abaqus files extension using oncaegraphicstartup() method

Everyone using abaqus encounters this cumbersome problem with dealing with abaqus CAE generating unnecessary (defers  case by case)  files ( extension ending with .res','.sel','.prt','.pac','.msg','.com','mdl','.dat','.abq','.stt','.odb_f’)  after performing a data check or generating a input deck or submitting a job.

So by utilizing abaqus oncaegraphicstartup() method, we can delete unnecessary files extension every time a abaqus cae gui is opened ( refer abaqus user manual for detail about oncaegraphicstartup() method)

Step 1:

Find the abaqus environment file in your default working directory and open  as text file

Look for  --->>>    abaqus_v6.env  file

Step 2:

Scroll all the way down . Then copy and paste below script and make sure script has consistent indentation .

Attention: If  script is pasted with a inconsistent indentation , they you will not be able to launch abaqus cae gui.

Note : script line starting with #   is treated as comment and line is ignore for execution

 

def onCaeGraphicsStartup():

 

# defining onCaeGraphicsStartup method

 

filename=['.res','.sel','.prt','.pac','.msg','.com','mdl','.dat','.abq','.stt','.odb_f']

# creating a list of all the extension file to be deleted

 

      for i in filename:

      # initialing a for loop to read the file extensions example : .res

            for file in os.listdir("."):

      # call a os.listdir function to read a list of entries in the directory given by “.” path

 

                  if file.endswith(i):

      # if a file name present in the filename list

                              print('Delelted :', file)

                              os.remove(file)

      # then remove the file

## end of script

 

Please leave your comments and thoughts on the script.

Thank you,

Prasanna Bhamidipati