CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > Siemens > STAR-CCM+

File names of automated PNG export of a scene

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By Marcel95

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 2, 2022, 13:45
Default File names of automated PNG export of a scene
  #1
New Member
 
Marcel
Join Date: Dec 2020
Location: Germany
Posts: 17
Rep Power: 6
Marcel95 is on a distinguished road
Good evening,

i export many PNG files during my unsteady simulation and i want to have them sorted by the time, they being created.

The problem is, that the name of the automated exported files consists of a base name (which i can define in StarCCM+, thats good) and a additional number. The Number is automatically generated by StarCCM+ and in my case (automated export is triggered by delta time) the number is the actuall physical time in the simulation during the export. The format of that physical time is the exponential scientific format. This last leads to my problem.

For example a exported png has the name: "Scalar_Scene01_5.4e-2"

When i want to sort those hundreds files by name, the following problem appears.

Windows thinks: Scalar_Scene01_5.4e-2 < Scalar_Scene01_5.5e-3
In words: When i sort by name, i have a problem with the scientific format.

Is there any possibility to change the scientific format in the file names to the regular format? Like 0.0032 instead of 3.2e-3? That would solve my problem.

Just sorting the files by the date of change doesnt work in my case. Because the files have all the same date of change, because i have to download them from the cluster to my pc first. They are not generated directly on my pc.

Sorry for that complicated explanation and thanks for any help!
Marcel95 is offline   Reply With Quote

Old   February 3, 2022, 06:34
Default
  #2
New Member
 
Nikola
Join Date: Dec 2014
Posts: 6
Rep Power: 12
shakabrade is on a distinguished road
Quote:
Originally Posted by Marcel95 View Post
Good evening,

i export many PNG files during my unsteady simulation and i want to have them sorted by the time, they being created.

The problem is, that the name of the automated exported files consists of a base name (which i can define in StarCCM+, thats good) and a additional number. The Number is automatically generated by StarCCM+ and in my case (automated export is triggered by delta time) the number is the actuall physical time in the simulation during the export. The format of that physical time is the exponential scientific format. This last leads to my problem.

For example a exported png has the name: "Scalar_Scene01_5.4e-2"

When i want to sort those hundreds files by name, the following problem appears.

Windows thinks: Scalar_Scene01_5.4e-2 < Scalar_Scene01_5.5e-3
In words: When i sort by name, i have a problem with the scientific format.

Is there any possibility to change the scientific format in the file names to the regular format? Like 0.0032 instead of 3.2e-3? That would solve my problem.

Just sorting the files by the date of change doesnt work in my case. Because the files have all the same date of change, because i have to download them from the cluster to my pc first. They are not generated directly on my pc.

Sorry for that complicated explanation and thanks for any help!
Hi, I had the same problem and created a python script to rename the contents in the folder. It bulldozes over everything it can so be careful.

The script:

import os


filename = r'PATH_TO_THE_FILE'
i = 0
for filename in os.listdir(filename):

name, ext = filename.rsplit(".",1)
what_i_want, the_rest = name.rsplit("_", 1)
the_rest_float=float(the_rest)
the_rest_int=int(the_rest_float*100000)
name_final=(str(the_rest_int) + '.' +ext)
os.rename(filename,name_final)
i = i +1
shakabrade is offline   Reply With Quote

Old   February 7, 2022, 07:13
Default
  #3
New Member
 
Marcel
Join Date: Dec 2020
Location: Germany
Posts: 17
Rep Power: 6
Marcel95 is on a distinguished road
Quote:
Originally Posted by shakabrade View Post
Hi, I had the same problem and created a python script to rename the contents in the folder. It bulldozes over everything it can so be careful.

The script:

import os


filename = r'PATH_TO_THE_FILE'
i = 0
for filename in os.listdir(filename):

name, ext = filename.rsplit(".",1)
what_i_want, the_rest = name.rsplit("_", 1)
the_rest_float=float(the_rest)
the_rest_int=int(the_rest_float*100000)
name_final=(str(the_rest_int) + '.' +ext)
os.rename(filename,name_final)
i = i +1

Hey shakabrade,

thank you very much for your Python script. I modified it a little bit and now it works perfectly for me. Thanks a lot.

Marcel
shakabrade likes this.
Marcel95 is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using PengRobinsonGas EoS with sprayFoam Jabo OpenFOAM Running, Solving & CFD 36 July 16, 2024 04:52
[foam-extend.org] Problems installing foam-extend-4.0 on openSUSE 42.2 and Ubuntu 16.04 ordinary OpenFOAM Installation 19 September 3, 2019 19:13
A CFX-POST error (ver 14.5.7) wangyflp88 CFX 2 July 22, 2017 01:17
Problem compiling a custom Lagrangian library brbbhatti OpenFOAM Programming & Development 2 July 7, 2014 12:32
DxFoam reader update hjasak OpenFOAM Post-Processing 69 April 24, 2008 02:24


All times are GMT -4. The time now is 21:04.