Sending both command file and JSON file via stdin?

Started by zerotrickpony, September 24, 2023, 01:45:31 PM

Previous topic - Next topic

zerotrickpony

Background:
Hi there, I am driving exiftool from a node.js process which works on MacOS, Windows, and Linux. I perform bulk write operations on potentially many (XX,XXXs) photos at once. I have both a very long JSON struct (MB) AND a very long command list (MB) for exiftool to work on. My parent process has these constructed in RAM, and I would like to send them both to exiftool somehow. I see how I could use stdin for one or the other, but not both. I am assuming that I will hit some kind of platform limitation if I try to use args, hence "-@ -". This leaves me writing the JSON struct to a tmp file.

Question:
Is there a way that I can avoid using a temp file, and send both the JSON and the command list via stdin?

Ideas:
I could imagine one of the command file lines being the entire gigantic JSON struct inline, I think I could avoid newlines in there since they'd be encoded? But I didn't see a way to do this in the docs. I could also imagine the command list being expressed as one item in the JSON struct, though then -@ would need some kind of "look in the JSON" flag which I didn't see. Or perhaps some tricks with stream reopening which I'm not experienced with? Or perhaps opening a named stream into exiftool, though idk if this is cross platform? Suggestions very welcome!

Footnote
Exiftool is astonishingly helpful, thank you so much for not just making it but continuing to maintain and support it. I have put it on a short list of delightfully overbuilt yet free utilities that I admire. (SQLite is also on this list.)

Phil Harvey

On Mac/Linux I think you could use named pipes to do this.  A quick Google seems to indicate you can do this in Windows too, but I don't have any experience there.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).