|
[Sponsors] |
File names of automated PNG export of a scene |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
February 2, 2022, 13:45 |
File names of automated PNG export of a scene
|
#1 |
New Member
Marcel
Join Date: Dec 2020
Location: Germany
Posts: 17
Rep Power: 6 |
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! |
|
February 3, 2022, 06:34 |
|
#2 | |
New Member
Nikola
Join Date: Dec 2014
Posts: 6
Rep Power: 12 |
Quote:
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 |
||
February 7, 2022, 07:13 |
|
#3 | |
New Member
Marcel
Join Date: Dec 2020
Location: Germany
Posts: 17
Rep Power: 6 |
Quote:
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 |
||
|
|
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 |