Situation:
I have a folder filled with .jpg files that have corrupt headers: .jpg files need to start with FF D8 FF E0 to be interpreted as images, but my files have random values in the first four bytes followed by FF D8 FF E0. I have been manually deleting the first four bytes with a browser based hex editor: https://hexed.it/. It works nicely, but I can only fix one file at a time, which is tedious.
QUESTION: Is there a way to use the command line to batch edit these files? What command would I use? I need specific instructions, because I lack CLI experience.
Here is an example of my situation:
I have 50 jpg files in a folder called KIimages. The files are all called "KIimage001", "KIimage002" and so on. I know how to open a folder in the terminal and list its contents. Then I get stuck. What do I do next to automate opening each image, deleting the first four bytes, and re-saving each file?
What I have tried: I read several articles/posts about writing scripts or using commands to do similar tasks, but but no instructions were clear or specific enough to be of any help, or the suggestions posted were above my skill level, which is basic.
I tried using the file command, and the head command, I also read about using something called dd, but the solutions were both too complicated, and not specific enough to my situation. Is there any way to do with simple terminal commands what I have described above?
Thanks.
FYI I am using Pop!_OS, in case that is relevant.