Batch edit fits headers

Apologies for raising an older thread, but thought it might be useful to provide some feedback.

I recently had cause to change the focal length in the FITS header for a series of shots taken back in 2017.  I was just starting to use SGP and really had not much of an idea of what I was doing (a bit like I am with PI right now).  Anyway, for some reason my focal length was set to 517mm in stead of 714mm per the ES ED102CF I have.

Anyway, after some reading and assistance from Rob for pointing me in the right direction, I eventually found and ran the script to change the focal length accordingly.  I found some interesting results however. 

Running the script on either my High Sierra iMac, or Win 10Pro PC, the script would append a . on the end of the digit so instead of getting 714 the value was 714.  Given it is a digit, it may well treat 714. as 714.00 therefore making no difference at all, but still thought it might be worth pointing out.



Well-known member
Use the script as attached in #19, but is may need modifying in a similar vein to that below


try changing this line in Juan's script
for ( let D = searchDirectory( inputDirectory + "*.fit", false/*recursive*/ ), i = 0; i < D.length; ++i )

to this
for ( let D = searchDirectory( inputDirectory + "*.xisf", false/*recursive*/ ), i = 0; i < D.length; ++i )

I don't know the exact format of xisf files so it may not work
Last edited:


Well-known member
Apr 17, 2019
Wells, Somerset, UK
I had a few problems with this script. Although the v1.0.1 script does not require input of the old keyword value, it still tests for it (so you still have to specify it anyway). Worse, the search strips the common FITS single quotes off the old value before comparing, so the specified old value must be without quotes, but the new value must include the quotes. It took me a while to figure this out. If you just want to ignore the old value and write a new value the attached script should do this. This version also replaces the ".fit" extension with ".xisf" (i.e. it looks for and changes ".xisf" files).