|
[Sponsors] |
Script for updating headers of files to current OF version |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
May 11, 2021, 04:27 |
Script for updating headers of files to current OF version
|
#1 |
Senior Member
Franco
Join Date: Nov 2019
Location: Compiègne, France
Posts: 129
Rep Power: 6 |
hello,
I have been playing around doing some scripts for other things, and I took the time to do a small script that will update the headers of the files to the current version of OF, and I thought to share it. It is more or less aesthetic, but as I use the files that I adapted to work in newer versions of OF (and that it had lost compatibility with the older ones...) I found updating the headers could be helpful. the script looks for all the files in the case, confirms that is an OF file by comparing the first and seventh line of the header (that is constant among the different versions of OF... or at least the ones I have used) Code:
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: v1912 | | \\ / A nd | Website: www.openfoam.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ Code:
/*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: 7 \\/ M anipulation | \*---------------------------------------------------------------------------*/ Code:
headerFile=$(find $FOAM_TUTORIALS -name "*controlDict*" |head -1) it is not a complicated thing to do but I thought that maybe someone will appreciate the share. in any case here it is (RenameHeaders.txt): Code:
#!/bin/bash cd "${0%/*}" || exit # Run from this directory . ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions #------------------------------------------------------------------------------ str1='/*--------------------------------*- C++ -*----------------------------------*\' str7='\*---------------------------------------------------------------------------*/' headerFile=$(find $FOAM_TUTORIALS -name "*controlDict*" |head -1) header=$(head -7 $headerFile) echo "Renaming headers to:" echo "$header" for dir in ./*/*; do #echo "$(head -1 $dir)" if [ -f "$dir" ]; then if [ "$str1" = "$(head -1 $dir)" ]; then if [ "$str7" = "$(head -7 $dir|tail -1)" ]; then #echo "$dir"_Temp tail +8 $dir > "$dir"_Temp echo "$header" | cat - "$dir"_Temp > temp && mv temp "$dir"_Temp mv "$dir"_Temp "$dir" fi fi fi done best regards! |
|
May 12, 2021, 03:57 |
|
#2 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,689
Rep Power: 40 |
||
May 12, 2021, 05:17 |
|
#3 | |
Senior Member
Franco
Join Date: Nov 2019
Location: Compiègne, France
Posts: 129
Rep Power: 6 |
Quote:
the script I uploaded in the first post of the thread works correctly, at least for my needs, I only wanted to share it with the community for anyone that could give a use or might be interested in it. best regards. |
||
December 4, 2022, 10:59 |
|
#4 | |
Super Moderator
Philip Cardiff
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 1,089
Rep Power: 34 |
Quote:
Is there a script like this for updating source code files? EDIT: I see that foam-extend has a foamChangeCopyright script. Last edited by bigphil; December 4, 2022 at 11:16. Reason: Add reference to foamChangeCopyright |
||
December 8, 2022, 10:27 |
|
#5 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,689
Rep Power: 40 |
Quote:
Hi Phil, This isn't something that we've needed much, since we like to preserve copyrights etc. However, on the few occasions where I've needed to make larger changes I have misc script snippets that I repurpose as needed. Cheers, /mark |
||
December 14, 2022, 10:11 |
|
#6 |
Super Moderator
Philip Cardiff
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 1,089
Rep Power: 34 |
Thanks Mark
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
reactingFoam crashes with no iterations | uckmhnds | OpenFOAM Running, Solving & CFD | 3 | July 17, 2022 18:41 |
different results form openfoam 3.0.1 to 1912 | yuno | OpenFOAM Running, Solving & CFD | 0 | September 28, 2020 03:09 |
paraview installation woes | vex | OpenFOAM Installation | 15 | January 30, 2011 07:11 |
[OpenFOAM] Problem with paraFoam on a linux-64 bit | bunni | ParaView | 4 | April 14, 2010 20:55 |
OpenFOAM15 paraFoam bug | koen | OpenFOAM Bugs | 19 | June 30, 2009 10:46 |